Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15422392
D7796.id.diff
No One
Temporary
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.id.diff
View Options
Index: src/applications/diffusion/engine/DiffusionCommitHookEngine.php
===================================================================
--- src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ 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));
+ }
+ }
+
+
}
Index: src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
===================================================================
--- src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
+++ 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;
+ }
+
}
Index: src/applications/herald/storage/HeraldRule.php
===================================================================
--- src/applications/herald/storage/HeraldRule.php
+++ 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/plain
Expires
Sun, Mar 23, 7:55 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7226025
Default Alt Text
D7796.id.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