1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Don't run Herald build rules when Differential revisions are updated automatically

Summary: Ref T2543. After D18731, Herald build rules run more often, but now incorrectly try to run builds when Diffusion closes a revision because a commit landed.

Test Plan: Made some mundane updates locally; this is tricky to test comprehensively locally so I'm mostly planning to just push it to `secure`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18745
This commit is contained in:
epriestley 2017-10-31 10:29:33 -07:00
parent 28cec2f8a2
commit 7fa0d066bc
2 changed files with 24 additions and 4 deletions

View file

@ -1204,16 +1204,32 @@ final class DifferentialTransactionEditor
// edited the title or changed subscribers), prevent "Run build plan" // edited the title or changed subscribers), prevent "Run build plan"
// and other similar rules from acting yet, since the build results will // and other similar rules from acting yet, since the build results will
// not (or, at least, should not) change unless the actual source changes. // not (or, at least, should not) change unless the actual source changes.
// We also don't run Differential builds if the update was caused by
// discovering a commit, as the expectation is that Diffusion builds take
// over once things land.
$has_update = false; $has_update = false;
$has_commit = false;
$type_update = DifferentialTransaction::TYPE_UPDATE; $type_update = DifferentialTransaction::TYPE_UPDATE;
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
if ($xaction->getTransactionType() == $type_update) { if ($xaction->getTransactionType() != $type_update) {
$has_update = true; continue;
break;
} }
if ($xaction->getMetadataValue('isCommitUpdate')) {
$has_commit = true;
} else {
$has_update = true;
}
break;
} }
if (!$has_update) { if ($has_commit) {
$adapter->setForbiddenAction(
HeraldBuildableState::STATECONST,
DifferentialHeraldStateReasons::REASON_LANDED);
} else if (!$has_update) {
$adapter->setForbiddenAction( $adapter->setForbiddenAction(
HeraldBuildableState::STATECONST, HeraldBuildableState::STATECONST,
DifferentialHeraldStateReasons::REASON_UNCHANGED); DifferentialHeraldStateReasons::REASON_UNCHANGED);

View file

@ -5,6 +5,7 @@ final class DifferentialHeraldStateReasons
const REASON_DRAFT = 'differential.draft'; const REASON_DRAFT = 'differential.draft';
const REASON_UNCHANGED = 'differential.unchanged'; const REASON_UNCHANGED = 'differential.unchanged';
const REASON_LANDED = 'differential.landed';
public function explainReason($reason) { public function explainReason($reason) {
$reasons = array( $reasons = array(
@ -14,6 +15,9 @@ final class DifferentialHeraldStateReasons
self::REASON_UNCHANGED => pht( self::REASON_UNCHANGED => pht(
'The update which triggered Herald did not update the diff for '. 'The update which triggered Herald did not update the diff for '.
'this revision, so builds will not run.'), 'this revision, so builds will not run.'),
self::REASON_LANDED => pht(
'The update which triggered Herald was an automatic update in '.
'response to discovering a commit, so builds will not run.'),
); );
return idx($reasons, $reason); return idx($reasons, $reason);