1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

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
This commit is contained in:
epriestley 2018-12-10 07:44:23 -08:00
parent 1a6a0181a8
commit c3206476a3
5 changed files with 20 additions and 10 deletions

View file

@ -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 ".

View file

@ -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;

View file

@ -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',

View file

@ -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 )------------------------------------------ */

View file

@ -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() {