Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F91281
D7796.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7796.diff
View Options
diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
--- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
@@ -934,4 +934,34 @@
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
--- a/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
+++ b/src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
@@ -5,6 +5,7 @@
private $log;
private $hookEngine;
private $changesets;
+ private $commitRef;
public function setPushLog(PhabricatorRepositoryPushLog $log) {
$this->log = $log;
@@ -84,6 +85,8 @@
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 @@
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
--- a/src/applications/herald/storage/HeraldRule.php
+++ b/src/applications/herald/storage/HeraldRule.php
@@ -16,7 +16,7 @@
protected $ruleType;
protected $isDisabled = 0;
- protected $configVersion = 18;
+ protected $configVersion = 19;
// phids for which this rule has been applied
private $ruleApplied = self::ATTACHABLE;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/3i/mx/fq7rejh3gxht67uc
Default Alt Text
D7796.diff (2 KB)
Attached To
Mode
D7796: Implement "Body" field in Herald pre-commit contnet hooks
Attached
Detach File
Event Timeline
Log In to Comment