From 2fd395e859bbb3eb040232493743bbbfa7af8487 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Thu, 28 Aug 2014 10:59:30 +1000 Subject: [PATCH] Allow pre-commit adapter to use custom actions Summary: Looks like I missed this when implementing custom actions and hence you can't currently use custom actions on the pre-commit adapters. Test Plan: Added a custom action to a pre-commit Herald rule. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10316 --- .../herald/HeraldPreCommitAdapter.php | 32 +++++++++++++------ .../herald/adapter/HeraldCommitAdapter.php | 4 ++- .../HeraldDifferentialRevisionAdapter.php | 4 ++- .../adapter/HeraldManiphestTaskAdapter.php | 4 ++- .../adapter/HeraldPholioMockAdapter.php | 4 ++- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php index 15832a08eb..61bcef4c33 100644 --- a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php @@ -72,16 +72,20 @@ abstract class HeraldPreCommitAdapter extends HeraldAdapter { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: - return array( - self::ACTION_BLOCK, - self::ACTION_EMAIL, - self::ACTION_NOTHING - ); + return array_merge( + array( + self::ACTION_BLOCK, + self::ACTION_EMAIL, + self::ACTION_NOTHING, + ), + parent::getActions($rule_type)); case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: - return array( - self::ACTION_EMAIL, - self::ACTION_NOTHING, - ); + return array_merge( + array( + self::ACTION_EMAIL, + self::ACTION_NOTHING, + ), + parent::getActions($rule_type)); } } @@ -118,7 +122,15 @@ abstract class HeraldPreCommitAdapter extends HeraldAdapter { pht('Blocked push.')); break; default: - throw new Exception(pht('No rules to handle action "%s"!', $action)); + $custom_result = parent::handleCustomHeraldEffect($effect); + if ($custom_result === null) { + throw new Exception(pht( + "No rules to handle action '%s'.", + $action)); + } + + $result[] = $custom_result; + break; } } diff --git a/src/applications/herald/adapter/HeraldCommitAdapter.php b/src/applications/herald/adapter/HeraldCommitAdapter.php index 90b3c91552..c749d835a1 100644 --- a/src/applications/herald/adapter/HeraldCommitAdapter.php +++ b/src/applications/herald/adapter/HeraldCommitAdapter.php @@ -544,7 +544,9 @@ final class HeraldCommitAdapter extends HeraldAdapter { default: $custom_result = parent::handleCustomHeraldEffect($effect); if ($custom_result === null) { - throw new Exception("No rules to handle action '{$action}'."); + throw new Exception(pht( + "No rules to handle action '%s'.", + $action)); } $result[] = $custom_result; diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php index ef436894b7..477d38bad5 100644 --- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php +++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php @@ -422,7 +422,9 @@ final class HeraldDifferentialRevisionAdapter default: $custom_result = parent::handleCustomHeraldEffect($effect); if ($custom_result === null) { - throw new Exception("No rules to handle action '{$action}'."); + throw new Exception(pht( + "No rules to handle action '%s'.", + $action)); } $result[] = $custom_result; diff --git a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php index 4376b2aded..ac0bbcad93 100644 --- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php +++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php @@ -207,7 +207,9 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { default: $custom_result = parent::handleCustomHeraldEffect($effect); if ($custom_result === null) { - throw new Exception("No rules to handle action '{$action}'."); + throw new Exception(pht( + "No rules to handle action '%s'.", + $action)); } $result[] = $custom_result; diff --git a/src/applications/herald/adapter/HeraldPholioMockAdapter.php b/src/applications/herald/adapter/HeraldPholioMockAdapter.php index 918e66e321..3752a733f3 100644 --- a/src/applications/herald/adapter/HeraldPholioMockAdapter.php +++ b/src/applications/herald/adapter/HeraldPholioMockAdapter.php @@ -139,7 +139,9 @@ final class HeraldPholioMockAdapter extends HeraldAdapter { default: $custom_result = parent::handleCustomHeraldEffect($effect); if ($custom_result === null) { - throw new Exception("No rules to handle action '{$action}'."); + throw new Exception(pht( + "No rules to handle action '%s'.", + $action)); } $result[] = $custom_result;