diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index 5471cd9165..3996b9ee6e 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -934,4 +934,34 @@ final class DiffusionCommitHookEngine extends Phobject { return $diff->getChangesets(); } + public function loadCommitRefForCommit($identifier) { + $repository = $this->getRepository(); + $vcs = $repository->getVersionControlSystem(); + switch ($vcs) { + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: + return id(new DiffusionLowLevelGitCommitQuery()) + ->setRepository($repository) + ->withIdentifier($identifier) + ->execute(); + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: + return id(new DiffusionLowLevelMercurialCommitQuery()) + ->setRepository($repository) + ->withIdentifier($identifier) + ->execute(); + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: + // For subversion, we need to use `svnlook`. + list($message) = execx( + 'svnlook log -t %s %s', + $this->subversionTransaction, + $this->subversionRepository); + + return id(new DiffusionCommitRef()) + ->setMessage($message); + break; + default: + throw new Exception(pht("Unknown VCS '%s!'", $vcs)); + } + } + + } diff --git a/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php b/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php index a12b0875c5..e65bc0643e 100644 --- a/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php +++ b/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php @@ -5,6 +5,7 @@ final class HeraldPreCommitContentAdapter extends HeraldAdapter { private $log; private $hookEngine; private $changesets; + private $commitRef; public function setPushLog(PhabricatorRepositoryPushLog $log) { $this->log = $log; @@ -84,6 +85,8 @@ final class HeraldPreCommitContentAdapter extends HeraldAdapter { public function getHeraldField($field) { $log = $this->getObject(); switch ($field) { + case self::FIELD_BODY: + return $this->getCommitRef()->getMessage(); case self::FIELD_DIFF_FILE: return $this->getDiffContent('name'); case self::FIELD_DIFF_CONTENT: @@ -179,4 +182,12 @@ final class HeraldPreCommitContentAdapter extends HeraldAdapter { return $result; } + private function getCommitRef() { + if ($this->commitRef === null) { + $this->commitRef = $this->hookEngine->loadCommitRefForCommit( + $this->log->getRefNew()); + } + return $this->commitRef; + } + } diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index aad5577611..21cba7ee9a 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -16,7 +16,7 @@ final class HeraldRule extends HeraldDAO protected $ruleType; protected $isDisabled = 0; - protected $configVersion = 18; + protected $configVersion = 19; // phids for which this rule has been applied private $ruleApplied = self::ATTACHABLE;