@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Explicitly decline to add commit authors as auditors from Herald

Summary:
Fixes T12304. If you have a Herald rule which tries to add a commit author as an auditor, it fails validation when trying to apply.

Stop trying to apply these transactions, and explicitly tell the user why. Differential already uses a similar ruleset around reviewers, but Audit was using older code.

Test Plan:
- Wrote a Herald rule to add A, B and C as auditors.
- Committed as A.
- After change, saw B and C added with transacript guidance that A was the author.

{F3235660}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12304

Differential Revision: https://secure.phabricator.com/D17404

+26
+26
src/applications/diffusion/herald/DiffusionAuditorsHeraldAction.php
··· 3 3 abstract class DiffusionAuditorsHeraldAction 4 4 extends HeraldAction { 5 5 6 + const DO_AUTHORS = 'do.authors'; 6 7 const DO_ADD_AUDITORS = 'do.add-auditors'; 7 8 8 9 public function getActionGroupKey() { ··· 19 20 20 21 $auditors = $object->getAudits(); 21 22 23 + // Don't try to add commit authors as auditors. 24 + $authors = array(); 25 + foreach ($phids as $key => $phid) { 26 + if ($phid == $object->getAuthorPHID()) { 27 + $authors[] = $phid; 28 + unset($phids[$key]); 29 + } 30 + } 31 + 32 + if ($authors) { 33 + $this->logEffect(self::DO_AUTHORS, $authors); 34 + if (!$phids) { 35 + return; 36 + } 37 + } 38 + 22 39 $current = array(); 23 40 foreach ($auditors as $auditor) { 24 41 if ($auditor->isInteresting()) { ··· 53 70 54 71 protected function getActionEffectMap() { 55 72 return array( 73 + self::DO_AUTHORS => array( 74 + 'icon' => 'fa-user', 75 + 'color' => 'grey', 76 + 'name' => pht('Commit Author'), 77 + ), 56 78 self::DO_ADD_AUDITORS => array( 57 79 'icon' => 'fa-user', 58 80 'color' => 'green', ··· 63 85 64 86 protected function renderActionEffectDescription($type, $data) { 65 87 switch ($type) { 88 + case self::DO_AUTHORS: 89 + return pht( 90 + 'Declined to add commit author as auditor: %s.', 91 + $this->renderHandleList($data)); 66 92 case self::DO_ADD_AUDITORS: 67 93 return pht( 68 94 'Added %s auditor(s): %s.',