1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 02:02:41 +01:00

Commit + Herald integration.

This commit is contained in:
epriestley 2011-04-04 14:12:20 -07:00
parent 06ae6e488b
commit cc66c4890d
12 changed files with 33 additions and 18 deletions

View file

@ -33,6 +33,7 @@ $conf['phabricator.env'] = $env;
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');
PhabricatorEnv::setEnvConfig($conf); PhabricatorEnv::setEnvConfig($conf);
phutil_load_library('arcanist/src');
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) { foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
phutil_load_library($library); phutil_load_library($library);

View file

@ -26,9 +26,3 @@ if (!@constant('__LIBPHUTIL__')) {
} }
phutil_load_library(dirname(__FILE__).'/../src/'); phutil_load_library(dirname(__FILE__).'/../src/');
phutil_require_module('phutil', 'symbols');
function __autoload($class) {
PhutilSymbolLoader::loadClass($class);
}

View file

@ -22,7 +22,7 @@ require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php'; require_once $root.'/scripts/__init_env__.php';
if (empty($argv[1])) { if (empty($argv[1])) {
echo "usage: parse_one_commit.php <commit_name>\n"; echo "usage: parse_one_commit.php <commit_name> [--herald]\n";
die(1); die(1);
} }
@ -72,6 +72,10 @@ switch ($repo->getVersionControlSystem()) {
throw new Exception("Unknown repository type!"); throw new Exception("Unknown repository type!");
} }
if (isset($argv[2]) && $argv[2] == '--herald') {
$workers[] = new PhabricatorRepositoryCommitHeraldWorker($spec);
}
ExecFuture::pushEchoMode(true); ExecFuture::pushEchoMode(true);
foreach ($workers as $worker) { foreach ($workers as $worker) {

View file

@ -46,7 +46,7 @@ class HeraldCommitAdapter extends HeraldObjectAdapter {
} }
public function getEmailPHIDs() { public function getEmailPHIDs() {
return $this->emailPHIDs; return array_keys($this->emailPHIDs);
} }
public function getHeraldName() { public function getHeraldName() {
@ -195,7 +195,7 @@ class HeraldCommitAdapter extends HeraldObjectAdapter {
break; break;
case HeraldActionConfig::ACTION_EMAIL: case HeraldActionConfig::ACTION_EMAIL:
foreach ($effect->getTarget() as $fbid) { foreach ($effect->getTarget() as $fbid) {
$this->emailPHIDs[] = $fbid; $this->emailPHIDs[$fbid] = true;
} }
$result[] = new HeraldApplyTranscript( $result[] = new HeraldApplyTranscript(
$effect, $effect,

View file

@ -33,7 +33,8 @@ class PhabricatorMetaMTASendController extends PhabricatorMetaMTAController {
$mail->setSimulatedFailureCount($request->getInt('failures')); $mail->setSimulatedFailureCount($request->getInt('failures'));
$mail->setIsHTML($request->getInt('html')); $mail->setIsHTML($request->getInt('html'));
$mail->save(); $mail->save();
if ($request->getInt('immediately')) { if ($request->getInt('immediately') &&
!PhabricatorEnv::getEnvConfig('metamta.send-immediately')) {
$mail->sendNow($force_send = true); $mail->sendNow($force_send = true);
} }

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'aphront/response/redirect'); phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/metamta/controller/base'); phutil_require_module('phabricator', 'applications/metamta/controller/base');
phutil_require_module('phabricator', 'applications/metamta/storage/mail'); phutil_require_module('phabricator', 'applications/metamta/storage/mail');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/form/base'); phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');

View file

@ -71,5 +71,17 @@ abstract class PhabricatorRepositoryCommitChangeParserWorker
return $result_map; return $result_map;
} }
protected function finishParse() {
$commit = $this->commit;
if ($this->shouldQueueFollowupTasks()) {
$task = new PhabricatorWorkerTask();
$task->setTaskClass('PhabricatorRepositoryCommitHeraldWorker');
$task->setData(
array(
'commitID' => $commit->getID(),
));
$task->save();
}
}
} }

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'applications/repository/storage/repository'); phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'applications/repository/worker/base'); phutil_require_module('phabricator', 'applications/repository/worker/base');
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
phutil_require_module('phabricator', 'storage/qsprintf'); phutil_require_module('phabricator', 'storage/qsprintf');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');

View file

@ -244,6 +244,8 @@ class PhabricatorRepositoryGitCommitChangeParserWorker
PhabricatorRepository::TABLE_PATHCHANGE, PhabricatorRepository::TABLE_PATHCHANGE,
implode(', ', $sql_chunk)); implode(', ', $sql_chunk));
} }
$this->finishParse();
} }
} }

View file

@ -366,6 +366,8 @@ class PhabricatorRepositorySvnCommitChangeParserWorker
$this->writeChanges($repository, $commit, $effects, $path_map, $commit_map); $this->writeChanges($repository, $commit, $effects, $path_map, $commit_map);
$this->writeBrowse($repository, $commit, $effects, $path_map); $this->writeBrowse($repository, $commit, $effects, $path_map);
$this->finishParse();
} }
private function writeChanges( private function writeChanges(

View file

@ -36,11 +36,11 @@ class PhabricatorRepositoryCommitHeraldWorker
$data); $data);
$engine = new HeraldEngine(); $engine = new HeraldEngine();
$effects = $engine->applyRules($this->rules, $adapter); $effects = $engine->applyRules($rules, $adapter);
$engine->applyEffects($effects, $adapter); $engine->applyEffects($effects, $adapter);
$phids = $adapter->getEmailPHIDs(); $email_phids = $adapter->getEmailPHIDs();
if (!$phids) { if (!$email_phids) {
return; return;
} }
@ -118,7 +118,8 @@ EOBODY;
$subject = "[Herald/Commit] {$commit_name} ({$who}){$name}"; $subject = "[Herald/Commit] {$commit_name} ({$who}){$name}";
$mailer = new PhabricatorMetaMTAMail(); $mailer = new PhabricatorMetaMTAMail();
$mailer->addTos($phids); $mailer->setRelatedPHID($commit->getPHID());
$mailer->addTos($email_phids);
$mailer->setSubject($subject); $mailer->setSubject($subject);
$mailer->setBody($body); $mailer->setBody($body);

View file

@ -170,10 +170,6 @@ function setup_aphront_basics() {
phutil_load_library('arcanist/src'); phutil_load_library('arcanist/src');
} }
function __autoload($class_name) {
PhutilSymbolLoader::loadClass($class_name);
}
function phabricator_fatal_config_error($msg) { function phabricator_fatal_config_error($msg) {
header('Content-Type: text/plain', $replace = true, $http_error = 500); header('Content-Type: text/plain', $replace = true, $http_error = 500);
$error = "CONFIG ERROR: ".$msg."\n"; $error = "CONFIG ERROR: ".$msg."\n";