mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14: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;
|
||||
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:
|
||||
return (($condition_value & $field_value) !== $condition_value);
|
||||
return (($condition_value & $field_value) !== (int) $condition_value);
|
||||
default:
|
||||
throw new HeraldInvalidConditionException(
|
||||
"Unknown condition '{$condition_type}'.");
|
||||
|
@ -1039,6 +1039,16 @@ abstract class HeraldAdapter {
|
|||
}
|
||||
}
|
||||
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:
|
||||
foreach ($value as $index => $val) {
|
||||
$handle = idx($handles, $val);
|
||||
|
|
|
@ -463,6 +463,8 @@ final class HeraldRuleController extends HeraldController {
|
|||
$rule->getRuleType());
|
||||
}
|
||||
|
||||
$changeflag_options =
|
||||
PhabricatorRepositoryPushLog::getHeraldChangeflagConditionOptions();
|
||||
Javelin::initBehavior(
|
||||
'herald-rule-editor',
|
||||
array(
|
||||
|
@ -490,16 +492,7 @@ final class HeraldRuleController extends HeraldController {
|
|||
'default' => PhabricatorRepositoryPushLog::REFTYPE_BRANCH,
|
||||
),
|
||||
HeraldPreCommitRefAdapter::VALUE_REF_CHANGE => array(
|
||||
'options' => 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'),
|
||||
),
|
||||
'options' => $changeflag_options,
|
||||
'default' => PhabricatorRepositoryPushLog::CHANGEFLAG_ADD,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -52,6 +52,18 @@ final class PhabricatorRepositoryPushLog
|
|||
->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() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
|
|
Loading…
Reference in a new issue