@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 an "Author's projects" Herald field to Differential

Summary:
Ref T1279. This allows installs to implement two different flavors of project review. They can either implement this rule:

When:
[ ... ] [ ... ]
Take Action:
[ Add blockign reviewers ] [ Security ]

...which means "every revision matching X needs to be signed off by someone else on the Security team, //even if the author is on that team//". The alternative is to implement this rule:

When:
[ Author's projects ] [ do not include ] [ Security ]
[ ... ] [ ... ]
Take Action:
[ Add blocking reviewers ] [ Security ]

...which means that people on the Security team don't need a separate signoff from someone else on the team.

I think this weaker version maps to some of what, e.g., Google does (you need to be reviewed by someone with "readability" in a language, but if you have it that's good enough), but I could imagine cases like "Security" wanting to prevent self-review from satisfying the requirement.

@zeeg, not sure which of these use cases is relevant here, but either one should work after this.

Test Plan: Created rules with this field, verified it populated properly in the transcript.

Reviewers: btrahan

Reviewed By: btrahan

CC: zeeg, aran

Maniphest Tasks: T1279

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

+20 -2
+6 -1
src/applications/herald/adapter/HeraldAdapter.php
··· 23 23 const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner'; 24 24 const FIELD_CONTENT_SOURCE = 'contentsource'; 25 25 const FIELD_ALWAYS = 'always'; 26 + const FIELD_AUTHOR_PROJECTS = 'authorprojects'; 26 27 27 28 const CONDITION_CONTAINS = 'contains'; 28 29 const CONDITION_NOT_CONTAINS = '!contains'; ··· 149 150 pht("Any affected package's owner"), 150 151 self::FIELD_CONTENT_SOURCE => pht('Content Source'), 151 152 self::FIELD_ALWAYS => pht('Always'), 153 + self::FIELD_AUTHOR_PROJECTS => pht("Author's projects"), 152 154 ); 153 155 } 154 156 ··· 166 168 self::CONDITION_IS_NOT_ANY => pht('is not any of'), 167 169 self::CONDITION_INCLUDE_ALL => pht('include all of'), 168 170 self::CONDITION_INCLUDE_ANY => pht('include any of'), 169 - self::CONDITION_INCLUDE_NONE => pht('include none of'), 171 + self::CONDITION_INCLUDE_NONE => pht('do not include'), 170 172 self::CONDITION_IS_ME => pht('is myself'), 171 173 self::CONDITION_IS_NOT_ME => pht('is not myself'), 172 174 self::CONDITION_REGEXP => pht('matches regexp'), ··· 201 203 case self::FIELD_TAGS: 202 204 case self::FIELD_REVIEWERS: 203 205 case self::FIELD_CC: 206 + case self::FIELD_AUTHOR_PROJECTS: 204 207 return array( 205 208 self::CONDITION_INCLUDE_ALL, 206 209 self::CONDITION_INCLUDE_ANY, ··· 588 591 return self::VALUE_TAG; 589 592 case self::FIELD_AFFECTED_PACKAGE: 590 593 return self::VALUE_OWNERS_PACKAGE; 594 + case self::FIELD_AUTHOR_PROJECTS: 595 + return self::VALUE_PROJECT; 591 596 default: 592 597 return self::VALUE_USER; 593 598 }
+13
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
··· 43 43 self::FIELD_TITLE, 44 44 self::FIELD_BODY, 45 45 self::FIELD_AUTHOR, 46 + self::FIELD_AUTHOR_PROJECTS, 46 47 self::FIELD_REVIEWERS, 47 48 self::FIELD_CC, 48 49 self::FIELD_REPOSITORY, ··· 287 288 case self::FIELD_AUTHOR: 288 289 return $this->revision->getAuthorPHID(); 289 290 break; 291 + case self::FIELD_AUTHOR_PROJECTS: 292 + $author_phid = $this->revision->getAuthorPHID(); 293 + if (!$author_phid) { 294 + return array(); 295 + } 296 + 297 + $projects = id(new PhabricatorProjectQuery()) 298 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 299 + ->withMemberPHIDs(array($author_phid)) 300 + ->execute(); 301 + 302 + return mpull($projects, 'getPHID'); 290 303 case self::FIELD_DIFF_FILE: 291 304 return $this->loadAffectedPaths(); 292 305 case self::FIELD_CC:
+1 -1
src/applications/herald/storage/HeraldRule.php
··· 13 13 protected $repetitionPolicy; 14 14 protected $ruleType; 15 15 16 - protected $configVersion = 12; 16 + protected $configVersion = 13; 17 17 18 18 private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied 19 19 private $validAuthor = self::ATTACHABLE;