mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
Herald - add field + condition for Diffusion Commits for "On autoclose branch"
Summary: Fixes T1461. Adds - FIELD_ALWAYS - now you could add this to a content type to always get notified - FIELD_REPOSITORY_AUTOCLOSE_BRANCH - solves T1461 - CONDITION_UNCONDITIONALLY - used by these two fields to not show any value for the user to select Test Plan: made a herald rule where diffs on autoclose branches would get flagged blue. made a diff on an autoclose branch and committed it. commit was flagged! Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T1461 Differential Revision: https://secure.phabricator.com/D7210
This commit is contained in:
parent
5200145b21
commit
3cf17cc67f
7 changed files with 113 additions and 66 deletions
|
@ -20,6 +20,7 @@ abstract class HeraldAdapter {
|
|||
const FIELD_AFFECTED_PACKAGE = 'affected-package';
|
||||
const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner';
|
||||
const FIELD_CONTENT_SOURCE = 'contentsource';
|
||||
const FIELD_ALWAYS = 'always';
|
||||
|
||||
const CONDITION_CONTAINS = 'contains';
|
||||
const CONDITION_NOT_CONTAINS = '!contains';
|
||||
|
@ -37,6 +38,7 @@ abstract class HeraldAdapter {
|
|||
const CONDITION_NOT_RULE = '!conditions';
|
||||
const CONDITION_EXISTS = 'exists';
|
||||
const CONDITION_NOT_EXISTS = '!exists';
|
||||
const CONDITION_UNCONDITIONALLY = 'unconditionally';
|
||||
const CONDITION_REGEXP_PAIR = 'regexp-pair';
|
||||
|
||||
const ACTION_ADD_CC = 'addcc';
|
||||
|
@ -79,6 +81,8 @@ abstract class HeraldAdapter {
|
|||
return null;
|
||||
case self::FIELD_CONTENT_SOURCE:
|
||||
return $this->getContentSource()->getSource();
|
||||
case self::FIELD_ALWAYS:
|
||||
return true;
|
||||
default:
|
||||
throw new Exception(
|
||||
"Unknown field '{$field_name}'!");
|
||||
|
@ -105,7 +109,11 @@ abstract class HeraldAdapter {
|
|||
/* -( Fields )------------------------------------------------------------- */
|
||||
|
||||
|
||||
abstract public function getFields();
|
||||
public function getFields() {
|
||||
return array(
|
||||
self::FIELD_ALWAYS,
|
||||
);
|
||||
}
|
||||
|
||||
public function getFieldNameMap() {
|
||||
return array(
|
||||
|
@ -124,7 +132,8 @@ abstract class HeraldAdapter {
|
|||
self::FIELD_AFFECTED_PACKAGE => pht('Any affected package'),
|
||||
self::FIELD_AFFECTED_PACKAGE_OWNER =>
|
||||
pht("Any affected package's owner"),
|
||||
self:: FIELD_CONTENT_SOURCE => pht('Content Source')
|
||||
self::FIELD_CONTENT_SOURCE => pht('Content Source'),
|
||||
self::FIELD_ALWAYS => pht('Always'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -150,6 +159,7 @@ abstract class HeraldAdapter {
|
|||
self::CONDITION_NOT_RULE => pht('does not match:'),
|
||||
self::CONDITION_EXISTS => pht('exists'),
|
||||
self::CONDITION_NOT_EXISTS => pht('does not exist'),
|
||||
self::CONDITION_UNCONDITIONALLY => '', // don't show anything!
|
||||
self::CONDITION_REGEXP_PAIR => pht('matches regexp pair'),
|
||||
);
|
||||
}
|
||||
|
@ -208,6 +218,10 @@ abstract class HeraldAdapter {
|
|||
self::CONDITION_IS,
|
||||
self::CONDITION_IS_NOT,
|
||||
);
|
||||
case self::FIELD_ALWAYS:
|
||||
return array(
|
||||
self::CONDITION_UNCONDITIONALLY,
|
||||
);
|
||||
default:
|
||||
throw new Exception(
|
||||
"This adapter does not define conditions for field '{$field}'!");
|
||||
|
@ -281,6 +295,8 @@ abstract class HeraldAdapter {
|
|||
return (bool)$field_value;
|
||||
case self::CONDITION_NOT_EXISTS:
|
||||
return !$field_value;
|
||||
case self::CONDITION_UNCONDITIONALLY:
|
||||
return (bool)$field_value;
|
||||
case self::CONDITION_REGEXP:
|
||||
foreach ((array)$field_value as $value) {
|
||||
// We add the 'S' flag because we use the regexp multiple times.
|
||||
|
@ -422,6 +438,7 @@ abstract class HeraldAdapter {
|
|||
case self::CONDITION_NOT_RULE:
|
||||
case self::CONDITION_EXISTS:
|
||||
case self::CONDITION_NOT_EXISTS:
|
||||
case self::CONDITION_UNCONDITIONALLY:
|
||||
// No explicit validation for these types, although there probably
|
||||
// should be in some cases.
|
||||
break;
|
||||
|
@ -559,6 +576,7 @@ abstract class HeraldAdapter {
|
|||
case self::CONDITION_IS_NOT_ME:
|
||||
case self::CONDITION_EXISTS:
|
||||
case self::CONDITION_NOT_EXISTS:
|
||||
case self::CONDITION_UNCONDITIONALLY:
|
||||
return self::VALUE_NONE;
|
||||
case self::CONDITION_RULE:
|
||||
case self::CONDITION_NOT_RULE:
|
||||
|
|
|
@ -9,6 +9,7 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
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;
|
||||
protected $revision;
|
||||
|
@ -46,11 +47,13 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
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();
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
return array_merge(
|
||||
array(
|
||||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
self::FIELD_COMMITTER,
|
||||
|
@ -65,7 +68,9 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
self::FIELD_DIFFERENTIAL_REVISION,
|
||||
self::FIELD_DIFFERENTIAL_REVIEWERS,
|
||||
self::FIELD_DIFFERENTIAL_CCS,
|
||||
);
|
||||
self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH,
|
||||
),
|
||||
parent::getFields());
|
||||
}
|
||||
|
||||
public function getConditionsForField($field) {
|
||||
|
@ -94,6 +99,10 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
self::CONDITION_INCLUDE_ANY,
|
||||
self::CONDITION_INCLUDE_NONE,
|
||||
);
|
||||
case self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH:
|
||||
return array(
|
||||
self::CONDITION_UNCONDITIONALLY,
|
||||
);
|
||||
}
|
||||
return parent::getConditionsForField($field);
|
||||
}
|
||||
|
@ -307,6 +316,10 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return array();
|
||||
}
|
||||
return $revision->getCCPHIDs();
|
||||
case self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH:
|
||||
return $this->repository->shouldAutocloseCommit(
|
||||
$this->commit,
|
||||
$this->commitData);
|
||||
}
|
||||
|
||||
return parent::getHeraldField($field);
|
||||
|
|
|
@ -34,7 +34,8 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
|
|||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
return array_merge(
|
||||
array(
|
||||
self::FIELD_TITLE,
|
||||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
|
@ -46,7 +47,8 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter {
|
|||
self::FIELD_RULE,
|
||||
self::FIELD_AFFECTED_PACKAGE,
|
||||
self::FIELD_AFFECTED_PACKAGE_OWNER,
|
||||
);
|
||||
),
|
||||
parent::getFields());
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
|
|
|
@ -47,13 +47,15 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
|||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
return array_merge(
|
||||
array(
|
||||
self::FIELD_TITLE,
|
||||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
self::FIELD_CC,
|
||||
self::FIELD_CONTENT_SOURCE,
|
||||
);
|
||||
),
|
||||
parent::getFields());
|
||||
}
|
||||
|
||||
public function getActions($rule_type) {
|
||||
|
|
|
@ -29,12 +29,14 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
|
|||
}
|
||||
|
||||
public function getFields() {
|
||||
return array(
|
||||
return array_merge(
|
||||
array(
|
||||
self::FIELD_TITLE,
|
||||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
self::FIELD_CC,
|
||||
);
|
||||
),
|
||||
parent::getFields());
|
||||
}
|
||||
|
||||
public function getActions($rule_type) {
|
||||
|
|
|
@ -13,7 +13,7 @@ final class HeraldRule extends HeraldDAO
|
|||
protected $repetitionPolicy;
|
||||
protected $ruleType;
|
||||
|
||||
protected $configVersion = 10;
|
||||
protected $configVersion = 11;
|
||||
|
||||
private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied
|
||||
private $validAuthor = self::ATTACHABLE;
|
||||
|
|
|
@ -163,6 +163,16 @@ JX.install('HeraldRuleEditor', {
|
|||
JX.DOM.setContent(condition_cell, condition_select);
|
||||
|
||||
this._onconditionchange(r);
|
||||
|
||||
var condition_name = this._config.conditions[row_id][1];
|
||||
switch (condition_name) {
|
||||
case 'unconditionally':
|
||||
JX.DOM.hide(condition_cell);
|
||||
break;
|
||||
default:
|
||||
JX.DOM.show(condition_cell);
|
||||
break;
|
||||
}
|
||||
},
|
||||
_onconditionchange : function(r) {
|
||||
var target = JX.DOM.find(r, 'select', 'condition-select');
|
||||
|
|
Loading…
Reference in a new issue