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

Implement "Body" field in Herald pre-commit content hooks

Summary: Ref T4195. Adds support for writing rules against commit message bodies.

Test Plan: Pushed git, hg, svn commits and verified their bodies populated correctly in transcripts.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4195

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

+42 -1
+30
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 934 934 return $diff->getChangesets(); 935 935 } 936 936 937 + public function loadCommitRefForCommit($identifier) { 938 + $repository = $this->getRepository(); 939 + $vcs = $repository->getVersionControlSystem(); 940 + switch ($vcs) { 941 + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 942 + return id(new DiffusionLowLevelGitCommitQuery()) 943 + ->setRepository($repository) 944 + ->withIdentifier($identifier) 945 + ->execute(); 946 + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 947 + return id(new DiffusionLowLevelMercurialCommitQuery()) 948 + ->setRepository($repository) 949 + ->withIdentifier($identifier) 950 + ->execute(); 951 + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 952 + // For subversion, we need to use `svnlook`. 953 + list($message) = execx( 954 + 'svnlook log -t %s %s', 955 + $this->subversionTransaction, 956 + $this->subversionRepository); 957 + 958 + return id(new DiffusionCommitRef()) 959 + ->setMessage($message); 960 + break; 961 + default: 962 + throw new Exception(pht("Unknown VCS '%s!'", $vcs)); 963 + } 964 + } 965 + 966 + 937 967 }
+11
src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
··· 5 5 private $log; 6 6 private $hookEngine; 7 7 private $changesets; 8 + private $commitRef; 8 9 9 10 public function setPushLog(PhabricatorRepositoryPushLog $log) { 10 11 $this->log = $log; ··· 84 85 public function getHeraldField($field) { 85 86 $log = $this->getObject(); 86 87 switch ($field) { 88 + case self::FIELD_BODY: 89 + return $this->getCommitRef()->getMessage(); 87 90 case self::FIELD_DIFF_FILE: 88 91 return $this->getDiffContent('name'); 89 92 case self::FIELD_DIFF_CONTENT: ··· 177 180 } 178 181 179 182 return $result; 183 + } 184 + 185 + private function getCommitRef() { 186 + if ($this->commitRef === null) { 187 + $this->commitRef = $this->hookEngine->loadCommitRefForCommit( 188 + $this->log->getRefNew()); 189 + } 190 + return $this->commitRef; 180 191 } 181 192 182 193 }
+1 -1
src/applications/herald/storage/HeraldRule.php
··· 16 16 protected $ruleType; 17 17 protected $isDisabled = 0; 18 18 19 - protected $configVersion = 18; 19 + protected $configVersion = 19; 20 20 21 21 // phids for which this rule has been applied 22 22 private $ruleApplied = self::ATTACHABLE;