Skip to content

Commit cc66c48

Browse files
author
epriestley
committedApr 4, 2011
Commit + Herald integration.
1 parent 06ae6e4 commit cc66c48

12 files changed

+33
-18
lines changed
 

‎scripts/__init_env__.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
phutil_require_module('phabricator', 'infrastructure/env');
3434
PhabricatorEnv::setEnvConfig($conf);
3535

36+
phutil_load_library('arcanist/src');
3637

3738
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
3839
phutil_load_library($library);

‎scripts/__init_script__.php

-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,3 @@
2626
}
2727

2828
phutil_load_library(dirname(__FILE__).'/../src/');
29-
30-
phutil_require_module('phutil', 'symbols');
31-
32-
function __autoload($class) {
33-
PhutilSymbolLoader::loadClass($class);
34-
}

‎scripts/repository/parse_one_commit.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
require_once $root.'/scripts/__init_env__.php';
2323

2424
if (empty($argv[1])) {
25-
echo "usage: parse_one_commit.php <commit_name>\n";
25+
echo "usage: parse_one_commit.php <commit_name> [--herald]\n";
2626
die(1);
2727
}
2828

@@ -72,6 +72,10 @@
7272
throw new Exception("Unknown repository type!");
7373
}
7474

75+
if (isset($argv[2]) && $argv[2] == '--herald') {
76+
$workers[] = new PhabricatorRepositoryCommitHeraldWorker($spec);
77+
}
78+
7579
ExecFuture::pushEchoMode(true);
7680

7781
foreach ($workers as $worker) {

‎src/applications/herald/adapter/commit/HeraldCommitAdapter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getPHID() {
4646
}
4747

4848
public function getEmailPHIDs() {
49-
return $this->emailPHIDs;
49+
return array_keys($this->emailPHIDs);
5050
}
5151

5252
public function getHeraldName() {
@@ -195,7 +195,7 @@ public function applyHeraldEffects(array $effects) {
195195
break;
196196
case HeraldActionConfig::ACTION_EMAIL:
197197
foreach ($effect->getTarget() as $fbid) {
198-
$this->emailPHIDs[] = $fbid;
198+
$this->emailPHIDs[$fbid] = true;
199199
}
200200
$result[] = new HeraldApplyTranscript(
201201
$effect,

‎src/applications/metamta/controller/send/PhabricatorMetaMTASendController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function processRequest() {
3333
$mail->setSimulatedFailureCount($request->getInt('failures'));
3434
$mail->setIsHTML($request->getInt('html'));
3535
$mail->save();
36-
if ($request->getInt('immediately')) {
36+
if ($request->getInt('immediately') &&
37+
!PhabricatorEnv::getEnvConfig('metamta.send-immediately')) {
3738
$mail->sendNow($force_send = true);
3839
}
3940

‎src/applications/metamta/controller/send/__init__.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
phutil_require_module('phabricator', 'aphront/response/redirect');
1010
phutil_require_module('phabricator', 'applications/metamta/controller/base');
1111
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
12+
phutil_require_module('phabricator', 'infrastructure/env');
1213
phutil_require_module('phabricator', 'view/form/base');
1314
phutil_require_module('phabricator', 'view/form/control/submit');
1415
phutil_require_module('phabricator', 'view/layout/panel');

‎src/applications/repository/worker/commitchangeparser/base/PhabricatorRepositoryCommitChangeParserWorker.php

+12
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,17 @@ private function lookupPaths(array $paths) {
7171
return $result_map;
7272
}
7373

74+
protected function finishParse() {
75+
$commit = $this->commit;
76+
if ($this->shouldQueueFollowupTasks()) {
77+
$task = new PhabricatorWorkerTask();
78+
$task->setTaskClass('PhabricatorRepositoryCommitHeraldWorker');
79+
$task->setData(
80+
array(
81+
'commitID' => $commit->getID(),
82+
));
83+
$task->save();
84+
}
85+
}
7486

7587
}

‎src/applications/repository/worker/commitchangeparser/base/__init__.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
phutil_require_module('phabricator', 'applications/repository/storage/repository');
1010
phutil_require_module('phabricator', 'applications/repository/worker/base');
11+
phutil_require_module('phabricator', 'infrastructure/daemon/workers/storage/task');
1112
phutil_require_module('phabricator', 'storage/qsprintf');
1213
phutil_require_module('phabricator', 'storage/queryfx');
1314

‎src/applications/repository/worker/commitchangeparser/git/PhabricatorRepositoryGitCommitChangeParserWorker.php

+2
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ protected function parseCommit(
244244
PhabricatorRepository::TABLE_PATHCHANGE,
245245
implode(', ', $sql_chunk));
246246
}
247+
248+
$this->finishParse();
247249
}
248250

249251
}

‎src/applications/repository/worker/commitchangeparser/svn/PhabricatorRepositorySvnCommitChangeParserWorker.php

+2
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ protected function parseCommit(
366366

367367
$this->writeChanges($repository, $commit, $effects, $path_map, $commit_map);
368368
$this->writeBrowse($repository, $commit, $effects, $path_map);
369+
370+
$this->finishParse();
369371
}
370372

371373
private function writeChanges(

‎src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function parseCommit(
3636
$data);
3737
$engine = new HeraldEngine();
3838

39-
$effects = $engine->applyRules($this->rules, $adapter);
39+
$effects = $engine->applyRules($rules, $adapter);
4040
$engine->applyEffects($effects, $adapter);
4141

42-
$phids = $adapter->getEmailPHIDs();
43-
if (!$phids) {
42+
$email_phids = $adapter->getEmailPHIDs();
43+
if (!$email_phids) {
4444
return;
4545
}
4646

@@ -118,7 +118,8 @@ public function parseCommit(
118118
$subject = "[Herald/Commit] {$commit_name} ({$who}){$name}";
119119

120120
$mailer = new PhabricatorMetaMTAMail();
121-
$mailer->addTos($phids);
121+
$mailer->setRelatedPHID($commit->getPHID());
122+
$mailer->addTos($email_phids);
122123
$mailer->setSubject($subject);
123124
$mailer->setBody($body);
124125

‎webroot/index.php

-4
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ function setup_aphront_basics() {
170170
phutil_load_library('arcanist/src');
171171
}
172172

173-
function __autoload($class_name) {
174-
PhutilSymbolLoader::loadClass($class_name);
175-
}
176-
177173
function phabricator_fatal_config_error($msg) {
178174
header('Content-Type: text/plain', $replace = true, $http_error = 500);
179175
$error = "CONFIG ERROR: ".$msg."\n";

0 commit comments

Comments
 (0)
Failed to load comments.