mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 19:49:02 +01:00
Define available Herald rule repetition options in terms of "isSingleEventAdapter()"
Summary: Depends on D18924. Ref T13048. Each adapter defines which repetition options ("every time", "only the first time") users may select for rules. Currently, this is all explicit and hard-coded. However, every adapter really just implements this rule (except for some bugs, see below): > You can pick "only the first time" if this adapter fires more than once on the same object. Since we already have a `isSingleEventAdapter()` method which lets us tell if an adapter fires more than once, just write this rule in the base class and delete all the copy/pasting. This also fixes two bugs because of the copy/pasting: Pholio Mocks and Phriction Documents did not allow you to write "only the first time" rules. There's no reason for this, they just didn't copy/paste enough methods when they were implemented. This will make a future diff (which introduces an "if the rule did not match last time" policy) cleaner. Test Plan: - Checked several different types of rules, saw appropriate options in the dropdown (pre-commit: no options; tasks: first or every). - Checked mocks and wiki docs, saw that you can now write "only the first time" rules. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13048 Differential Revision: https://secure.phabricator.com/D18925
This commit is contained in:
parent
042c43d6d8
commit
a90b16e83a
10 changed files with 13 additions and 64 deletions
|
@ -49,13 +49,6 @@ final class PhabricatorCalendarEventHeraldAdapter extends HeraldAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function getHeraldName() {
|
||||
return $this->getObject()->getMonogram();
|
||||
}
|
||||
|
|
|
@ -53,12 +53,6 @@ final class HeraldDifferentialDiffAdapter extends HeraldDifferentialAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function getHeraldName() {
|
||||
return pht('New Diff');
|
||||
}
|
||||
|
|
|
@ -69,13 +69,6 @@ final class HeraldDifferentialRevisionAdapter
|
|||
}
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public static function newLegacyAdapter(
|
||||
DifferentialRevision $revision,
|
||||
DifferentialDiff $diff) {
|
||||
|
|
|
@ -764,9 +764,19 @@ abstract class HeraldAdapter extends Phobject {
|
|||
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
);
|
||||
$options = array();
|
||||
|
||||
$options[] = HeraldRepetitionPolicyConfig::EVERY;
|
||||
|
||||
// Some rules, like pre-commit rules, only ever fire once. It doesn't
|
||||
// make sense to use state-based repetition policies like "only the first
|
||||
// time" for these rules.
|
||||
|
||||
if (!$this->isSingleEventAdapter()) {
|
||||
$options[] = HeraldRepetitionPolicyConfig::FIRST;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function initializeNewAdapter() {
|
||||
|
|
|
@ -33,13 +33,6 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
|
@ -49,12 +49,6 @@ final class PhabricatorMailOutboundMailHeraldAdapter
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
|
@ -24,13 +24,6 @@ final class HeraldPhameBlogAdapter extends HeraldAdapter {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
|
@ -24,13 +24,6 @@ final class HeraldPhamePostAdapter extends HeraldAdapter {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
|
@ -39,13 +39,6 @@ final class HeraldPonderQuestionAdapter extends HeraldAdapter {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
|
@ -24,13 +24,6 @@ final class PhabricatorProjectHeraldAdapter extends HeraldAdapter {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getRepetitionOptions() {
|
||||
return array(
|
||||
HeraldRepetitionPolicyConfig::EVERY,
|
||||
HeraldRepetitionPolicyConfig::FIRST,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsRuleType($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
|
Loading…
Add table
Reference in a new issue