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

When a draft's builds fail and it demotes to "Changes Planned + Draft", notify the author (only) via email

Summary:
Depends on D19288. Ref T13110. In addition to kicking revisions back to "Changes Planned" when builds fail, notify the author that they need to fix their awful garbage change.

(The actual email could be more useful than it currently is.)

Test Plan: Created a revision with failing remote builds, saw email about the problem generate.

Maniphest Tasks: T13110

Differential Revision: https://secure.phabricator.com/D19289
This commit is contained in:
epriestley 2018-04-03 09:51:01 -07:00
parent f4f3311312
commit 804f9817c3

View file

@ -11,6 +11,7 @@ final class DifferentialTransactionEditor
private $affectedPaths; private $affectedPaths;
private $firstBroadcast = false; private $firstBroadcast = false;
private $wasBroadcasting; private $wasBroadcasting;
private $isDraftDemotion;
public function getEditorApplicationClass() { public function getEditorApplicationClass() {
return 'PhabricatorDifferentialApplication'; return 'PhabricatorDifferentialApplication';
@ -134,6 +135,11 @@ final class DifferentialTransactionEditor
// as "Commented" later. This should get cleaner after T10967. // as "Commented" later. This should get cleaner after T10967.
$this->hasReviewTransaction = true; $this->hasReviewTransaction = true;
break; break;
case DifferentialRevisionPlanChangesTransaction::TRANSACTIONTYPE:
if ($xaction->getMetadataValue('draft.demote')) {
$this->isDraftDemotion = true;
}
break;
} }
} }
@ -497,15 +503,11 @@ final class DifferentialTransactionEditor
protected function shouldSendMail( protected function shouldSendMail(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
if (!$object->getShouldBroadcast()) {
return false;
}
return true; return true;
} }
protected function getMailTo(PhabricatorLiskDAO $object) { protected function getMailTo(PhabricatorLiskDAO $object) {
if ($object->getShouldBroadcast()) {
$this->requireReviewers($object); $this->requireReviewers($object);
$phids = array(); $phids = array();
@ -520,6 +522,25 @@ final class DifferentialTransactionEditor
return $phids; return $phids;
} }
// If we're demoting a draft after a build failure, just notify the author.
if ($this->isDraftDemotion) {
$author_phid = $object->getAuthorPHID();
return array(
$author_phid,
);
}
return array();
}
protected function getMailCC(PhabricatorLiskDAO $object) {
if (!$object->getShouldBroadcast()) {
return array();
}
return parent::getMailCC($object);
}
protected function newMailUnexpandablePHIDs(PhabricatorLiskDAO $object) { protected function newMailUnexpandablePHIDs(PhabricatorLiskDAO $object) {
$this->requireReviewers($object); $this->requireReviewers($object);
@ -1408,12 +1429,14 @@ final class DifferentialTransactionEditor
return array( return array(
'changedPriorToCommitURI' => $this->changedPriorToCommitURI, 'changedPriorToCommitURI' => $this->changedPriorToCommitURI,
'firstBroadcast' => $this->firstBroadcast, 'firstBroadcast' => $this->firstBroadcast,
'isDraftDemotion' => $this->isDraftDemotion,
); );
} }
protected function loadCustomWorkerState(array $state) { protected function loadCustomWorkerState(array $state) {
$this->changedPriorToCommitURI = idx($state, 'changedPriorToCommitURI'); $this->changedPriorToCommitURI = idx($state, 'changedPriorToCommitURI');
$this->firstBroadcast = idx($state, 'firstBroadcast'); $this->firstBroadcast = idx($state, 'firstBroadcast');
$this->isDraftDemotion = idx($state, 'isDraftDemotion');
return $this; return $this;
} }