Page MenuHomePhabricator

D15254.id36808.diff
No OneTemporary

D15254.id36808.diff

diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -14,6 +14,7 @@
const CONDITION_IS_ME = 'me';
const CONDITION_IS_NOT_ME = '!me';
const CONDITION_REGEXP = 'regexp';
+ const CONDITION_NOT_REGEXP = '!regexp';
const CONDITION_RULE = 'conditions';
const CONDITION_NOT_RULE = '!conditions';
const CONDITION_EXISTS = 'exists';
@@ -322,6 +323,7 @@
self::CONDITION_IS_ME => pht('is myself'),
self::CONDITION_IS_NOT_ME => pht('is not myself'),
self::CONDITION_REGEXP => pht('matches regexp'),
+ self::CONDITION_NOT_REGEXP => pht('does not match regexp'),
self::CONDITION_RULE => pht('matches:'),
self::CONDITION_NOT_RULE => pht('does not match:'),
self::CONDITION_EXISTS => pht('exists'),
@@ -364,16 +366,18 @@
switch ($condition_type) {
case self::CONDITION_CONTAINS:
- // "Contains" can take an array of strings, as in "Any changed
- // filename" for diffs.
+ case self::CONDITION_NOT_CONTAINS:
+ // "Contains and "does not contain" can take an array of strings, as in
+ // "Any changed filename" for diffs.
+
+ $result_if_match = ($condition_type == self::CONDITION_CONTAINS);
+
foreach ((array)$field_value as $value) {
if (stripos($value, $condition_value) !== false) {
- return true;
+ return $result_if_match;
}
}
- return false;
- case self::CONDITION_NOT_CONTAINS:
- return (stripos($field_value, $condition_value) === false);
+ return !$result_if_match;
case self::CONDITION_IS:
return ($field_value == $condition_value);
case self::CONDITION_IS_NOT:
@@ -427,6 +431,9 @@
case self::CONDITION_NEVER:
return false;
case self::CONDITION_REGEXP:
+ case self::CONDITION_NOT_REGEXP:
+ $result_if_match = ($condition_type == self::CONDITION_REGEXP);
+
foreach ((array)$field_value as $value) {
// We add the 'S' flag because we use the regexp multiple times.
// It shouldn't cause any troubles if the flag is already there
@@ -437,10 +444,10 @@
pht('Regular expression is not valid!'));
}
if ($result) {
- return true;
+ return $result_if_match;
}
}
- return false;
+ return !$result_if_match;
case self::CONDITION_REGEXP_PAIR:
// Match a JSON-encoded pair of regular expressions against a
// dictionary. The first regexp must match the dictionary key, and the
@@ -509,6 +516,7 @@
switch ($condition_type) {
case self::CONDITION_REGEXP:
+ case self::CONDITION_NOT_REGEXP:
$ok = @preg_match($condition_value, '');
if ($ok === false) {
throw new HeraldInvalidConditionException(
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -47,6 +47,7 @@
HeraldAdapter::CONDITION_IS,
HeraldAdapter::CONDITION_IS_NOT,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
);
case self::STANDARD_PHID:
return array(
@@ -76,12 +77,16 @@
case self::STANDARD_TEXT_LIST:
return array(
HeraldAdapter::CONDITION_CONTAINS,
+ HeraldAdapter::CONDITION_NOT_CONTAINS,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
);
case self::STANDARD_TEXT_MAP:
return array(
HeraldAdapter::CONDITION_CONTAINS,
+ HeraldAdapter::CONDITION_NOT_CONTAINS,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
HeraldAdapter::CONDITION_REGEXP_PAIR,
);
}
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -1446,5 +1446,19 @@
return null;
}
+ public function getHeraldFieldStandardType() {
+ if ($this->proxy) {
+ return $this->proxy->getHeraldFieldStandardType();
+ }
+ return null;
+ }
+
+ public function getHeraldDatasource() {
+ if ($this->proxy) {
+ return $this->proxy->getHeraldDatasource();
+ }
+ return null;
+ }
+
}
diff --git a/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php b/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php
--- a/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php
+++ b/src/infrastructure/customfield/herald/PhabricatorCustomFieldHeraldField.php
@@ -65,8 +65,20 @@
return $this->getCustomField()->getHeraldFieldConditions();
}
+ protected function getHeraldFieldStandardType() {
+ return $this->getCustomField()->getHeraldFieldStandardType();
+ }
+
public function getHeraldFieldValueType($condition) {
+ if ($this->getHeraldFieldStandardType()) {
+ return parent::getHeraldFieldValueType($condition);
+ }
+
return $this->getCustomField()->getHeraldFieldValueType($condition);
}
+ protected function getDatasource() {
+ return $this->getCustomField()->getHeraldDatasource();
+ }
+
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
@@ -129,6 +129,10 @@
);
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_BOOL;
+ }
+
protected function getHTTPParameterType() {
return new AphrontBoolHTTPParameterType();
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
@@ -77,9 +77,14 @@
HeraldAdapter::CONDITION_IS,
HeraldAdapter::CONDITION_IS_NOT,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
);
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_TEXT;
+ }
+
protected function getHTTPParameterType() {
return new AphrontStringHTTPParameterType();
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php
@@ -241,6 +241,10 @@
);
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_PHID_NULLABLE;
+ }
+
public function getHeraldFieldValue() {
// If the field has a `null` value, make sure we hand an `array()` to
// Herald.
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
@@ -92,9 +92,14 @@
HeraldAdapter::CONDITION_IS,
HeraldAdapter::CONDITION_IS_NOT,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
);
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_TEXT;
+ }
+
protected function getHTTPParameterType() {
return new AphrontStringHTTPParameterType();
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php
@@ -60,9 +60,14 @@
HeraldAdapter::CONDITION_IS,
HeraldAdapter::CONDITION_IS_NOT,
HeraldAdapter::CONDITION_REGEXP,
+ HeraldAdapter::CONDITION_NOT_REGEXP,
);
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_TEXT;
+ }
+
protected function getHTTPParameterType() {
return new AphrontStringHTTPParameterType();
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
@@ -44,4 +44,12 @@
->setDatasource($this->getDatasource());
}
+ public function getHeraldFieldStandardType() {
+ return HeraldField::STANDARD_PHID_LIST;
+ }
+
+ public function getHeraldDatasource() {
+ return $this->getDatasource();
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Oct 18 2024, 8:23 PM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6728588
Default Alt Text
D15254.id36808.diff (9 KB)

Event Timeline