@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.

Add "pusher is committer" to Herald as a pre-commit rule

Summary:
Fixes T4594. Also, allow "exists" / "does not exist" to be run against author/committer. This allows construction of rules like:

- Committer identities must be authentic.
- Committer identities must be resolvable.
- Author identities must be resolvable.

Test Plan: Created some rules using these new rules and ran them.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: aran, epriestley

Maniphest Tasks: T4594

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

+14 -10
+8 -7
src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
··· 39 39 self::FIELD_REPOSITORY_PROJECTS, 40 40 self::FIELD_PUSHER, 41 41 self::FIELD_PUSHER_PROJECTS, 42 + self::FIELD_PUSHER_IS_COMMITTER, 42 43 self::FIELD_DIFFERENTIAL_REVISION, 43 44 self::FIELD_DIFFERENTIAL_ACCEPTED, 44 45 self::FIELD_DIFFERENTIAL_REVIEWERS, ··· 116 117 return $revision->getCCPHIDs(); 117 118 case self::FIELD_IS_MERGE_COMMIT: 118 119 return $this->getIsMergeCommit(); 120 + case self::FIELD_PUSHER_IS_COMMITTER: 121 + $pusher_phid = $this->getHookEngine()->getViewer()->getPHID(); 122 + return ($this->getCommitterPHID() == $pusher_phid); 119 123 } 120 124 121 125 return parent::getHeraldField($field); ··· 202 206 switch ($vcs) { 203 207 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 204 208 case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 205 - // Here, if there's no committer, we're going to return the author 206 - // instead. 209 + // If there's no committer information, we're going to return the 210 + // author instead. However, if there's committer information and we 211 + // can't resolve it, return `null`. 207 212 $ref = $this->getCommitRef(); 208 213 $committer = $ref->getCommitter(); 209 214 if (!strlen($committer)) { 210 215 return $this->getAuthorPHID(); 211 216 } 212 - $phid = $this->lookupUser($committer); 213 - if (!$phid) { 214 - return $this->getAuthorPHID(); 215 - } 216 - return $phid; 217 + return $this->lookupUser($committer); 217 218 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 218 219 // In Subversion, the pusher is always the committer. 219 220 return $this->getHookEngine()->getViewer()->getPHID();
+5 -2
src/applications/herald/adapter/HeraldAdapter.php
··· 41 41 const FIELD_IS_NEW_OBJECT = 'new-object'; 42 42 const FIELD_TASK_PRIORITY = 'taskpriority'; 43 43 const FIELD_ARCANIST_PROJECT = 'arcanist-project'; 44 + const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer'; 44 45 45 46 const CONDITION_CONTAINS = 'contains'; 46 47 const CONDITION_NOT_CONTAINS = '!contains'; ··· 240 241 self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'), 241 242 self::FIELD_TASK_PRIORITY => pht('Task priority'), 242 243 self::FIELD_ARCANIST_PROJECT => pht('Arcanist Project'), 244 + self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'), 243 245 ); 244 246 } 245 247 ··· 287 289 self::CONDITION_IS_NOT, 288 290 self::CONDITION_REGEXP, 289 291 ); 290 - case self::FIELD_AUTHOR: 291 - case self::FIELD_COMMITTER: 292 292 case self::FIELD_REVIEWER: 293 293 case self::FIELD_PUSHER: 294 294 case self::FIELD_TASK_PRIORITY: ··· 299 299 ); 300 300 case self::FIELD_REPOSITORY: 301 301 case self::FIELD_ASSIGNEE: 302 + case self::FIELD_AUTHOR: 303 + case self::FIELD_COMMITTER: 302 304 return array( 303 305 self::CONDITION_IS_ANY, 304 306 self::CONDITION_IS_NOT_ANY, ··· 372 374 case self::FIELD_IS_MERGE_COMMIT: 373 375 case self::FIELD_DIFF_ENORMOUS: 374 376 case self::FIELD_IS_NEW_OBJECT: 377 + case self::FIELD_PUSHER_IS_COMMITTER: 375 378 return array( 376 379 self::CONDITION_IS_TRUE, 377 380 self::CONDITION_IS_FALSE,
+1 -1
src/applications/herald/storage/HeraldRule.php
··· 17 17 protected $isDisabled = 0; 18 18 protected $triggerObjectPHID; 19 19 20 - protected $configVersion = 32; 20 + protected $configVersion = 33; 21 21 22 22 // phids for which this rule has been applied 23 23 private $ruleApplied = self::ATTACHABLE;