Page MenuHomePhabricator

D7806.diff
No OneTemporary

D7806.diff

Index: src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
===================================================================
--- src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
+++ src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
@@ -6,6 +6,8 @@
private $hookEngine;
private $changesets;
private $commitRef;
+ private $fields;
+ private $revision = false;
public function setPushLog(PhabricatorRepositoryPushLog $log) {
$this->log = $log;
@@ -47,6 +49,9 @@
self::FIELD_REPOSITORY,
self::FIELD_PUSHER,
self::FIELD_PUSHER_PROJECTS,
+ self::FIELD_DIFFERENTIAL_REVISION,
+ self::FIELD_DIFFERENTIAL_REVIEWERS,
+ self::FIELD_DIFFERENTIAL_CCS,
self::FIELD_RULE,
),
parent::getFields());
@@ -107,6 +112,24 @@
return $this->hookEngine->getViewer()->getPHID();
case self::FIELD_PUSHER_PROJECTS:
return $this->hookEngine->loadViewerProjectPHIDsForHerald();
+ case self::FIELD_DIFFERENTIAL_REVISION:
+ $revision = $this->getRevision();
+ if (!$revision) {
+ return null;
+ }
+ return $revision->getPHID();
+ case self::FIELD_DIFFERENTIAL_REVIEWERS:
+ $revision = $this->getRevision();
+ if (!$revision) {
+ return array();
+ }
+ return $revision->getReviewers();
+ case self::FIELD_DIFFERENTIAL_CCS:
+ $revision = $this->getRevision();
+ if (!$revision) {
+ return array();
+ }
+ return $revision->getCCPHIDs();
}
return parent::getHeraldField($field);
@@ -244,4 +267,32 @@
->execute();
}
+ private function getCommitFields() {
+ if ($this->fields === null) {
+ $this->fields = id(new DiffusionLowLevelCommitFieldsQuery())
+ ->setRepository($this->hookEngine->getRepository())
+ ->withCommitRef($this->getCommitRef())
+ ->execute();
+ }
+ return $this->fields;
+ }
+
+ private function getRevision() {
+ if ($this->revision === false) {
+ $fields = $this->getCommitFields();
+ $revision_id = idx($fields, 'revisionID');
+ if (!$revision_id) {
+ $this->revision = null;
+ } else {
+ $this->revision = id(new DifferentialRevisionQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withIDs(array($revision_id))
+ ->needRelationships(true)
+ ->executeOne();
+ }
+ }
+
+ return $this->revision;
+ }
+
}
Index: src/applications/herald/adapter/HeraldAdapter.php
===================================================================
--- src/applications/herald/adapter/HeraldAdapter.php
+++ src/applications/herald/adapter/HeraldAdapter.php
@@ -27,6 +27,9 @@
const FIELD_PROJECTS = 'projects';
const FIELD_PUSHER = 'pusher';
const FIELD_PUSHER_PROJECTS = 'pusher-projects';
+ const FIELD_DIFFERENTIAL_REVISION = 'differential-revision';
+ const FIELD_DIFFERENTIAL_REVIEWERS = 'differential-reviewers';
+ const FIELD_DIFFERENTIAL_CCS = 'differential-ccs';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@@ -163,6 +166,9 @@
self::FIELD_PROJECTS => pht("Projects"),
self::FIELD_PUSHER => pht('Pusher'),
self::FIELD_PUSHER_PROJECTS => pht("Pusher's projects"),
+ self::FIELD_DIFFERENTIAL_REVISION => pht('Differential revision'),
+ self::FIELD_DIFFERENTIAL_REVIEWERS => pht('Differential reviewers'),
+ self::FIELD_DIFFERENTIAL_CCS => pht('Differential CCs'),
);
}
@@ -263,6 +269,25 @@
return array(
self::CONDITION_UNCONDITIONALLY,
);
+ case self::FIELD_DIFFERENTIAL_REVIEWERS:
+ return array(
+ self::CONDITION_EXISTS,
+ self::CONDITION_NOT_EXISTS,
+ self::CONDITION_INCLUDE_ALL,
+ self::CONDITION_INCLUDE_ANY,
+ self::CONDITION_INCLUDE_NONE,
+ );
+ case self::FIELD_DIFFERENTIAL_CCS:
+ return array(
+ self::CONDITION_INCLUDE_ALL,
+ self::CONDITION_INCLUDE_ANY,
+ self::CONDITION_INCLUDE_NONE,
+ );
+ case self::FIELD_DIFFERENTIAL_REVISION:
+ return array(
+ self::CONDITION_EXISTS,
+ self::CONDITION_NOT_EXISTS,
+ );
default:
throw new Exception(
"This adapter does not define conditions for field '{$field}'!");
Index: src/applications/herald/adapter/HeraldCommitAdapter.php
===================================================================
--- src/applications/herald/adapter/HeraldCommitAdapter.php
+++ src/applications/herald/adapter/HeraldCommitAdapter.php
@@ -6,9 +6,6 @@
final class HeraldCommitAdapter extends HeraldAdapter {
const FIELD_NEED_AUDIT_FOR_PACKAGE = 'need-audit-for-package';
- const FIELD_DIFFERENTIAL_REVISION = 'differential-revision';
- const FIELD_DIFFERENTIAL_REVIEWERS = 'differential-reviewers';
- const FIELD_DIFFERENTIAL_CCS = 'differential-ccs';
const FIELD_REPOSITORY_AUTOCLOSE_BRANCH = 'repository-autoclose-branch';
protected $diff;
@@ -49,9 +46,6 @@
return array(
self::FIELD_NEED_AUDIT_FOR_PACKAGE =>
pht('Affected packages that need audit'),
- self::FIELD_DIFFERENTIAL_REVISION => pht('Differential revision'),
- self::FIELD_DIFFERENTIAL_REVIEWERS => pht('Differential reviewers'),
- self::FIELD_DIFFERENTIAL_CCS => pht('Differential CCs'),
self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH => pht('On autoclose branch'),
) + parent::getFieldNameMap();
}
@@ -82,25 +76,6 @@
public function getConditionsForField($field) {
switch ($field) {
- case self::FIELD_DIFFERENTIAL_REVIEWERS:
- return array(
- self::CONDITION_EXISTS,
- self::CONDITION_NOT_EXISTS,
- self::CONDITION_INCLUDE_ALL,
- self::CONDITION_INCLUDE_ANY,
- self::CONDITION_INCLUDE_NONE,
- );
- case self::FIELD_DIFFERENTIAL_CCS:
- return array(
- self::CONDITION_INCLUDE_ALL,
- self::CONDITION_INCLUDE_ANY,
- self::CONDITION_INCLUDE_NONE,
- );
- case self::FIELD_DIFFERENTIAL_REVISION:
- return array(
- self::CONDITION_EXISTS,
- self::CONDITION_NOT_EXISTS,
- );
case self::FIELD_NEED_AUDIT_FOR_PACKAGE:
return array(
self::CONDITION_INCLUDE_ANY,

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 13, 1:34 PM (6 d, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746481
Default Alt Text
D7806.diff (6 KB)

Event Timeline