@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 Owners Package support for "Commit Hook: Content" Herald rules

Summary:
See PHI370. Support the "Affected packages" and "Affected package owners" Herald fields in pre-commit hooks.

I believe there's no technical reason these fields aren't supported and this was just overlooked.

Test Plan: Wrote a rule which makes use of the new fields, pushed commits through it. Checked transcripts and saw sensible-looking values.

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

+85 -1
+4
src/__phutil_library_map__.php
··· 812 812 'DiffusionPreCommitContentHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentHeraldField.php', 813 813 'DiffusionPreCommitContentMergeHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php', 814 814 'DiffusionPreCommitContentMessageHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php', 815 + 'DiffusionPreCommitContentPackageHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPackageHeraldField.php', 816 + 'DiffusionPreCommitContentPackageOwnerHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPackageOwnerHeraldField.php', 815 817 'DiffusionPreCommitContentPusherHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php', 816 818 'DiffusionPreCommitContentPusherIsCommitterHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php', 817 819 'DiffusionPreCommitContentPusherProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php', ··· 6007 6009 'DiffusionPreCommitContentHeraldField' => 'HeraldField', 6008 6010 'DiffusionPreCommitContentMergeHeraldField' => 'DiffusionPreCommitContentHeraldField', 6009 6011 'DiffusionPreCommitContentMessageHeraldField' => 'DiffusionPreCommitContentHeraldField', 6012 + 'DiffusionPreCommitContentPackageHeraldField' => 'DiffusionPreCommitContentHeraldField', 6013 + 'DiffusionPreCommitContentPackageOwnerHeraldField' => 'DiffusionPreCommitContentHeraldField', 6010 6014 'DiffusionPreCommitContentPusherHeraldField' => 'DiffusionPreCommitContentHeraldField', 6011 6015 'DiffusionPreCommitContentPusherIsCommitterHeraldField' => 'DiffusionPreCommitContentHeraldField', 6012 6016 'DiffusionPreCommitContentPusherProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField',
+29
src/applications/diffusion/herald/DiffusionPreCommitContentPackageHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentPackageHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.package'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected packages'); 10 + } 11 + 12 + public function getFieldGroupKey() { 13 + return HeraldRelatedFieldGroup::FIELDGROUPKEY; 14 + } 15 + 16 + public function getHeraldFieldValue($object) { 17 + $packages = $this->getAdapter()->loadAffectedPackages(); 18 + return mpull($packages, 'getPHID'); 19 + } 20 + 21 + protected function getHeraldFieldStandardType() { 22 + return self::STANDARD_PHID_LIST; 23 + } 24 + 25 + protected function getDatasource() { 26 + return new PhabricatorOwnersPackageDatasource(); 27 + } 28 + 29 + }
+34
src/applications/diffusion/herald/DiffusionPreCommitContentPackageOwnerHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentPackageOwnerHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.package.owners'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected package owners'); 10 + } 11 + 12 + public function getFieldGroupKey() { 13 + return HeraldRelatedFieldGroup::FIELDGROUPKEY; 14 + } 15 + 16 + public function getHeraldFieldValue($object) { 17 + $packages = $this->getAdapter()->loadAffectedPackages(); 18 + if (!$packages) { 19 + return array(); 20 + } 21 + 22 + $owners = PhabricatorOwnersOwner::loadAllForPackages($packages); 23 + return mpull($owners, 'getUserPHID'); 24 + } 25 + 26 + protected function getHeraldFieldStandardType() { 27 + return self::STANDARD_PHID_LIST; 28 + } 29 + 30 + protected function getDatasource() { 31 + return new PhabricatorProjectOrUserDatasource(); 32 + } 33 + 34 + }
+14
src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
··· 7 7 private $fields; 8 8 private $revision = false; 9 9 10 + private $affectedPackages; 11 + 10 12 public function getAdapterContentName() { 11 13 return pht('Commit Hook: Commit Content'); 12 14 } ··· 222 224 return $this->getHookEngine()->loadBranches( 223 225 $this->getObject()->getRefNew()); 224 226 } 227 + 228 + public function loadAffectedPackages() { 229 + if ($this->affectedPackages === null) { 230 + $packages = PhabricatorOwnersPackage::loadAffectedPackages( 231 + $this->getHookEngine()->getRepository(), 232 + $this->getDiffContent('name')); 233 + $this->affectedPackages = $packages; 234 + } 235 + 236 + return $this->affectedPackages; 237 + } 238 + 225 239 226 240 }
+4 -1
src/applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php
··· 18 18 } 19 19 20 20 public function isManagementPanel() { 21 - if (!$this->isUserPanel()) { 21 + return false; 22 + /* 23 + if (!$this->isUserPanel()) { 22 24 return false; 23 25 } 24 26 ··· 27 29 } 28 30 29 31 return false; 32 + */ 30 33 } 31 34 32 35 public function isTemplatePanel() {