1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

Herald - Add "new" field to herald

Summary: ...and surface it in all adapters except commit adapters. Values are true or false. Ref T4294

Test Plan: made a herald rule to be cc'd on new tasks. was cc'd on new tasks and not cc'd on updates to existing tasks.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4294

Differential Revision: https://secure.phabricator.com/D8142
This commit is contained in:
Bob Trahan 2014-02-04 10:43:31 -10:00
parent 073f566100
commit 9be4df02c2
6 changed files with 23 additions and 0 deletions

View file

@ -256,6 +256,7 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$adapter->setExplicitCCs($new['ccs']);
$adapter->setExplicitReviewers($new['rev']);
$adapter->setForbiddenCCs($revision->loadUnsubscribedPHIDs());
$adapter->setIsNewObject($is_new);
$xscript = HeraldEngine::loadAndApplyRules($adapter);
$xscript_uri = '/herald/transcript/'.$xscript->getID().'/';

View file

@ -38,6 +38,7 @@ abstract class HeraldAdapter {
const FIELD_BRANCHES = 'branches';
const FIELD_AUTHOR_RAW = 'author-raw';
const FIELD_COMMITTER_RAW = 'committer-raw';
const FIELD_IS_NEW_OBJECT = 'new-object';
const CONDITION_CONTAINS = 'contains';
const CONDITION_NOT_CONTAINS = '!contains';
@ -90,6 +91,7 @@ abstract class HeraldAdapter {
const VALUE_BUILD_PLAN = 'buildplan';
private $contentSource;
private $isNewObject;
public function setContentSource(PhabricatorContentSource $content_source) {
$this->contentSource = $content_source;
@ -99,6 +101,18 @@ abstract class HeraldAdapter {
return $this->contentSource;
}
public function getIsNewObject() {
if (is_bool($this->isNewObject)) {
return $this->isNewObject;
}
throw new Exception(pht('You must setIsNewObject to a boolean first!'));
}
public function setIsNewObject($new) {
$this->isNewObject = (bool) $new;
return $this;
}
abstract public function getPHID();
abstract public function getHeraldName();
@ -110,6 +124,8 @@ abstract class HeraldAdapter {
return $this->getContentSource()->getSource();
case self::FIELD_ALWAYS:
return true;
case self::FIELD_IS_NEW_OBJECT:
return $this->getIsNewObject();
default:
throw new Exception(
"Unknown field '{$field_name}'!");
@ -216,6 +232,7 @@ abstract class HeraldAdapter {
self::FIELD_BRANCHES => pht('Commit\'s branches'),
self::FIELD_AUTHOR_RAW => pht('Raw author name'),
self::FIELD_COMMITTER_RAW => pht('Raw committer name'),
self::FIELD_IS_NEW_OBJECT => pht('Is newly created?'),
);
}
@ -345,6 +362,7 @@ abstract class HeraldAdapter {
);
case self::FIELD_IS_MERGE_COMMIT:
case self::FIELD_DIFF_ENORMOUS:
case self::FIELD_IS_NEW_OBJECT:
return array(
self::CONDITION_IS_TRUE,
self::CONDITION_IS_FALSE,

View file

@ -72,6 +72,7 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
self::FIELD_RULE,
self::FIELD_AFFECTED_PACKAGE,
self::FIELD_AFFECTED_PACKAGE_OWNER,
self::FIELD_OBJECT_IS_NEW,
),
parent::getFields());
}

View file

@ -80,6 +80,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
self::FIELD_CC,
self::FIELD_CONTENT_SOURCE,
self::FIELD_PROJECTS,
self::FIELD_IS_NEW_OBJECT,
),
parent::getFields());
}

View file

@ -59,6 +59,7 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
self::FIELD_BODY,
self::FIELD_AUTHOR,
self::FIELD_CC,
self::FIELD_OBJECT_IS_NEW,
),
parent::getFields());
}

View file

@ -1554,6 +1554,7 @@ abstract class PhabricatorApplicationTransactionEditor
$adapter = $this->buildHeraldAdapter($object, $xactions);
$adapter->setContentSource($this->getContentSource());
$adapter->setIsNewObject($this->getIsNewObject());
$xscript = HeraldEngine::loadAndApplyRules($adapter);
$this->setHeraldAdapter($adapter);