From c3206476a303556f19e8dc4c058030005172ca9b Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 10 Dec 2018 07:44:23 -0800 Subject: [PATCH] Give "Autoclose Only" repository detail proper getters/setters Summary: Ref T13222. See D19829. We're inconsistent about using `getDetail()/setDetail()` to do some ad-hoc reads. Put this stuff in proper accessor methods. Also a couple of text fixes from D19850. Test Plan: Set, edited, and removed autoclose branches from a repository. Got sensible persistence and rendering behavior. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13222 Differential Revision: https://secure.phabricator.com/D19856 --- .../editor/DiffusionRepositoryEditEngine.php | 3 +-- .../DiffusionRepositoryBranchesManagementPanel.php | 6 ++++-- .../PhabricatorRepositoryManagementThawWorkflow.php | 6 +++--- .../repository/storage/PhabricatorRepository.php | 11 ++++++++++- .../PhabricatorRepositoryAutocloseOnlyTransaction.php | 4 ++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php index 29dc588b45..e570b6debe 100644 --- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php @@ -215,8 +215,7 @@ final class DiffusionRepositoryEditEngine $track_value = $object->getDetail('branch-filter', array()); $track_value = array_keys($track_value); - $autoclose_value = $object->getDetail('close-commits-filter', array()); - $autoclose_value = array_keys($autoclose_value); + $autoclose_value = $object->getAutocloseOnlyRules(); $automation_instructions = pht( "Configure **Repository Automation** to allow Phabricator to ". diff --git a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php index e3ace3a5a5..77a13c07a1 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php @@ -24,7 +24,7 @@ final class DiffusionRepositoryBranchesManagementPanel $has_any = $repository->getDetail('default-branch') || $repository->getDetail('branch-filter') || - $repository->getDetail('close-commits-filter'); + $repository->getAutocloseOnlyRules(); if ($has_any) { return 'fa-code-fork'; @@ -83,8 +83,10 @@ final class DiffusionRepositoryBranchesManagementPanel phutil_tag('em', array(), pht('Track All Branches'))); $view->addProperty(pht('Track Only'), $track_only); + $autoclose_rules = $repository->getAutocloseOnlyRules(); + $autoclose_rules = implode(', ', $autoclose_rules); $autoclose_only = nonempty( - $repository->getHumanReadableDetail('close-commits-filter', array()), + $autoclose_rules, phutil_tag('em', array(), pht('Autoclose On All Branches'))); $autoclose_disabled = false; diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementThawWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementThawWorkflow.php index 3743045c34..7ca725de81 100644 --- a/src/applications/repository/management/PhabricatorRepositoryManagementThawWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementThawWorkflow.php @@ -15,11 +15,11 @@ final class PhabricatorRepositoryManagementThawWorkflow array( array( 'name' => 'demote', - 'param' => 'device/service', + 'param' => 'device|service', 'help' => pht( 'Demote a device (or all devices in a service) discarding '. - 'local changes. Clears stuck write locks and recovers from '. - 'lost leaders.'), + 'unsynchronized changes. Clears stuck write locks and recovers '. + 'from lost leaders.'), ), array( 'name' => 'promote', diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index c961e06f27..302ef82a48 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -244,7 +244,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO switch ($key) { case 'branch-filter': - case 'close-commits-filter': $value = array_keys($value); $value = implode(', ', $value); break; @@ -1202,6 +1201,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO return null; } + public function getAutocloseOnlyRules() { + return array_keys($this->getDetail('close-commits-filter', array())); + } + + public function setAutocloseOnlyRules(array $rules) { + $rules = array_fill_keys($rules, true); + $this->setDetail('close-commits-filter', $rules); + return $this; + } + /* -( Repository URI Management )------------------------------------------ */ diff --git a/src/applications/repository/xaction/PhabricatorRepositoryAutocloseOnlyTransaction.php b/src/applications/repository/xaction/PhabricatorRepositoryAutocloseOnlyTransaction.php index feacc73c44..5ff17c4b05 100644 --- a/src/applications/repository/xaction/PhabricatorRepositoryAutocloseOnlyTransaction.php +++ b/src/applications/repository/xaction/PhabricatorRepositoryAutocloseOnlyTransaction.php @@ -6,11 +6,11 @@ final class PhabricatorRepositoryAutocloseOnlyTransaction const TRANSACTIONTYPE = 'repo:autoclose-only'; public function generateOldValue($object) { - return array_keys($object->getDetail('close-commits-filter', array())); + return $object->getAutocloseOnlyRules(); } public function applyInternalEffects($object, $value) { - $object->setDetail('close-commits-filter', array_fill_keys($value, true)); + $object->setAutocloseOnlyRules($value); } public function getTitle() {