Page MenuHomePhabricator

D20468.id48822.diff
No OneTemporary

D20468.id48822.diff

diff --git a/src/applications/diffusion/herald/HeraldCommitAdapter.php b/src/applications/diffusion/herald/HeraldCommitAdapter.php
--- a/src/applications/diffusion/herald/HeraldCommitAdapter.php
+++ b/src/applications/diffusion/herald/HeraldCommitAdapter.php
@@ -180,27 +180,18 @@
if ($this->affectedRevision === null) {
$this->affectedRevision = false;
- $commit = $this->getObject();
- $data = $commit->getCommitData();
-
- $revision_id = $data->getCommitDetail('differential.revisionID');
- if ($revision_id) {
- // NOTE: The Herald rule owner might not actually have access to
- // the revision, and can control which revision a commit is
- // associated with by putting text in the commit message. However,
- // the rules they can write against revisions don't actually expose
- // anything interesting, so it seems reasonable to load unconditionally
- // here.
-
- $revision = id(new DifferentialRevisionQuery())
- ->withIDs(array($revision_id))
- ->setViewer($viewer)
- ->needReviewers(true)
- ->executeOne();
- if ($revision) {
- $this->affectedRevision = $revision;
- }
- }
+ // NOTE: The Herald rule owner might not actually have access to
+ // the revision, and can control which revision a commit is
+ // associated with by putting text in the commit message. However,
+ // the rules they can write against revisions don't actually expose
+ // anything interesting, so it seems reasonable to load unconditionally
+ // here.
+
+ $revision = DiffusionCommitRevisionQuery::loadRevisionForCommit(
+ $viewer,
+ $this->getObject());
+
+ $this->affectedRevision = $revision;
}
return $this->affectedRevision;
diff --git a/src/applications/diffusion/query/DiffusionCommitRevisionQuery.php b/src/applications/diffusion/query/DiffusionCommitRevisionQuery.php
--- a/src/applications/diffusion/query/DiffusionCommitRevisionQuery.php
+++ b/src/applications/diffusion/query/DiffusionCommitRevisionQuery.php
@@ -45,4 +45,23 @@
return $map;
}
+ public static function loadRevisionForCommit(
+ PhabricatorUser $viewer,
+ PhabricatorRepositoryCommit $commit) {
+
+ $data = $commit->getCommitData();
+
+ $revision_id = $data->getCommitDetail('differential.revisionID');
+ if (!$revision_id) {
+ return null;
+ }
+
+ return id(new DifferentialRevisionQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($revision_id))
+ ->needReviewers(true)
+ ->executeOne();
+ }
+
+
}
diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php
--- a/src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php
+++ b/src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php
@@ -135,16 +135,10 @@
$data = $commit->getCommitData();
$author_phid = $data->getCommitDetail('authorPHID');
- $revision_id = $data->getCommitDetail('differential.revisionID');
- if ($revision_id) {
- $revision = id(new DifferentialRevisionQuery())
- ->setViewer($viewer)
- ->withIDs(array($revision_id))
- ->needReviewers(true)
- ->executeOne();
- } else {
- $revision = null;
- }
+
+ $revision = DiffusionCommitRevisionQuery::loadRevisionForCommit(
+ $viewer,
+ $commit);
$requests = $commit->getAudits();
$requests = mpull($requests, null, 'getAuditorPHID');

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 9:00 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7717265
Default Alt Text
D20468.id48822.diff (3 KB)

Event Timeline