mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Herald - fix change type bug
Summary: wasn't working due to some type issues. Fixes T4756. I also made it display nicer while I was debugging this. Test Plan: created a herald rule to block changes that added refs. git tag -a "test" -m "test test"; git push origin test got me blocked! Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4756 Differential Revision: https://secure.phabricator.com/D8724
This commit is contained in:
parent
582ec54465
commit
d5ded805b2
3 changed files with 27 additions and 12 deletions
|
@ -544,9 +544,9 @@ abstract class HeraldAdapter {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
case self::CONDITION_HAS_BIT:
|
case self::CONDITION_HAS_BIT:
|
||||||
return (($condition_value & $field_value) === $condition_value);
|
return (($condition_value & $field_value) === (int) $condition_value);
|
||||||
case self::CONDITION_NOT_BIT:
|
case self::CONDITION_NOT_BIT:
|
||||||
return (($condition_value & $field_value) !== $condition_value);
|
return (($condition_value & $field_value) !== (int) $condition_value);
|
||||||
default:
|
default:
|
||||||
throw new HeraldInvalidConditionException(
|
throw new HeraldInvalidConditionException(
|
||||||
"Unknown condition '{$condition_type}'.");
|
"Unknown condition '{$condition_type}'.");
|
||||||
|
@ -1039,6 +1039,16 @@ abstract class HeraldAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HeraldPreCommitRefAdapter::FIELD_REF_CHANGE:
|
||||||
|
$change_map =
|
||||||
|
PhabricatorRepositoryPushLog::getHeraldChangeflagConditionOptions();
|
||||||
|
foreach ($value as $index => $val) {
|
||||||
|
$name = idx($change_map, $val);
|
||||||
|
if ($name) {
|
||||||
|
$value[$index] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
foreach ($value as $index => $val) {
|
foreach ($value as $index => $val) {
|
||||||
$handle = idx($handles, $val);
|
$handle = idx($handles, $val);
|
||||||
|
|
|
@ -463,6 +463,8 @@ final class HeraldRuleController extends HeraldController {
|
||||||
$rule->getRuleType());
|
$rule->getRuleType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$changeflag_options =
|
||||||
|
PhabricatorRepositoryPushLog::getHeraldChangeflagConditionOptions();
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'herald-rule-editor',
|
'herald-rule-editor',
|
||||||
array(
|
array(
|
||||||
|
@ -490,16 +492,7 @@ final class HeraldRuleController extends HeraldController {
|
||||||
'default' => PhabricatorRepositoryPushLog::REFTYPE_BRANCH,
|
'default' => PhabricatorRepositoryPushLog::REFTYPE_BRANCH,
|
||||||
),
|
),
|
||||||
HeraldPreCommitRefAdapter::VALUE_REF_CHANGE => array(
|
HeraldPreCommitRefAdapter::VALUE_REF_CHANGE => array(
|
||||||
'options' => array(
|
'options' => $changeflag_options,
|
||||||
PhabricatorRepositoryPushLog::CHANGEFLAG_ADD =>
|
|
||||||
pht('change creates ref'),
|
|
||||||
PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE =>
|
|
||||||
pht('change deletes ref'),
|
|
||||||
PhabricatorRepositoryPushLog::CHANGEFLAG_REWRITE =>
|
|
||||||
pht('change rewrites ref'),
|
|
||||||
PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS =>
|
|
||||||
pht('dangerous change'),
|
|
||||||
),
|
|
||||||
'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD,
|
'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -52,6 +52,18 @@ final class PhabricatorRepositoryPushLog
|
||||||
->setPusherPHID($viewer->getPHID());
|
->setPusherPHID($viewer->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getHeraldChangeflagConditionOptions() {
|
||||||
|
return array(
|
||||||
|
PhabricatorRepositoryPushLog::CHANGEFLAG_ADD =>
|
||||||
|
pht('change creates ref'),
|
||||||
|
PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE =>
|
||||||
|
pht('change deletes ref'),
|
||||||
|
PhabricatorRepositoryPushLog::CHANGEFLAG_REWRITE =>
|
||||||
|
pht('change rewrites ref'),
|
||||||
|
PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS =>
|
||||||
|
pht('dangerous change'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_AUX_PHID => true,
|
self::CONFIG_AUX_PHID => true,
|
||||||
|
|
Loading…
Reference in a new issue