1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Don't disrupt repository import chain when publishing is disabled

Summary:
Fixes T4736. Currently, we incorrectly skip the `writeImportStatusFlag()` call if publishing is disabled (the `herald-disabled`) check. This means we don't flag the commit as imported, and don't move the pipeline forward correctly.

Instead, we only want to skip the owners stuff, not the pipeline stuff. Move that to a method.

(Also fix a nearby TODO now that we have a permanent failure exception.)

Test Plan:
  - Used `scripts/repository/reparse.php --owners ...` to execute this code, fiddled with things to hit both the disabled and enabled branches and verified the flag stuff is still reached.
  - Faked the exceptions and made sure they raise correctly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4736

Differential Revision: https://secure.phabricator.com/D8715
This commit is contained in:
epriestley 2014-04-08 05:13:28 -07:00
parent cd829434d4
commit bd0011076b
2 changed files with 22 additions and 14 deletions

View file

@ -7,6 +7,24 @@ final class PhabricatorRepositoryCommitOwnersWorker
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
$this->triggerOwnerAudits($repository, $commit);
$commit->writeImportStatusFlag(
PhabricatorRepositoryCommit::IMPORTED_OWNERS);
if ($this->shouldQueueFollowupTasks()) {
PhabricatorWorker::scheduleTask(
'PhabricatorRepositoryCommitHeraldWorker',
array(
'commitID' => $commit->getID(),
));
}
}
private function triggerOwnerAudits(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
if ($repository->getDetail('herald-disabled')) {
return;
}
@ -61,17 +79,6 @@ final class PhabricatorRepositoryCommitOwnersWorker
$commit->updateAuditStatus($requests);
$commit->save();
}
$commit->writeImportStatusFlag(
PhabricatorRepositoryCommit::IMPORTED_OWNERS);
if ($this->shouldQueueFollowupTasks()) {
PhabricatorWorker::scheduleTask(
'PhabricatorRepositoryCommitHeraldWorker',
array(
'commitID' => $commit->getID(),
));
}
}
private function checkAuditReasons(

View file

@ -13,14 +13,15 @@ abstract class PhabricatorRepositoryCommitParserWorker
$commit_id = idx($this->getTaskData(), 'commitID');
if (!$commit_id) {
return false;
throw new PhabricatorWorkerPermanentFailureException(
pht('No "%s" in task data.', 'commitID'));
}
$commit = id(new PhabricatorRepositoryCommit())->load($commit_id);
if (!$commit) {
// TODO: Communicate permanent failure?
return false;
throw new PhabricatorWorkerPermanentFailureException(
pht('Commit "%s" does not exist.', $commit_id));
}
return $this->commit = $commit;