1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Give "Track Only" repository detail proper getters/setters

Summary: Depends on D19856. Ref T13222. See D19829. Make access to "Track Only" slightly cleaner and more consistent..

Test Plan: Set, edited, and removed "Track Only" settings for a repository. Saw sensible persistence and display behaviors.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222

Differential Revision: https://secure.phabricator.com/D19857
This commit is contained in:
epriestley 2018-12-10 08:05:13 -08:00
parent c3206476a3
commit bf6c534b56
6 changed files with 20 additions and 27 deletions

View file

@ -212,9 +212,7 @@ final class DiffusionRepositoryEditEngine
->setObject($object) ->setObject($object)
->execute(); ->execute();
$track_value = $object->getDetail('branch-filter', array()); $track_value = $object->getTrackOnlyRules();
$track_value = array_keys($track_value);
$autoclose_value = $object->getAutocloseOnlyRules(); $autoclose_value = $object->getAutocloseOnlyRules();
$automation_instructions = pht( $automation_instructions = pht(

View file

@ -23,7 +23,7 @@ final class DiffusionRepositoryBranchesManagementPanel
$has_any = $has_any =
$repository->getDetail('default-branch') || $repository->getDetail('default-branch') ||
$repository->getDetail('branch-filter') || $repository->getTrackOnlyRules() ||
$repository->getAutocloseOnlyRules(); $repository->getAutocloseOnlyRules();
if ($has_any) { if ($has_any) {
@ -74,12 +74,14 @@ final class DiffusionRepositoryBranchesManagementPanel
->setViewer($viewer); ->setViewer($viewer);
$default_branch = nonempty( $default_branch = nonempty(
$repository->getHumanReadableDetail('default-branch'), $repository->getDetail('default-branch'),
phutil_tag('em', array(), $repository->getDefaultBranch())); phutil_tag('em', array(), $repository->getDefaultBranch()));
$view->addProperty(pht('Default Branch'), $default_branch); $view->addProperty(pht('Default Branch'), $default_branch);
$track_only_rules = $repository->getTrackOnlyRules();
$track_only_rules = implode(', ', $track_only_rules);
$track_only = nonempty( $track_only = nonempty(
$repository->getHumanReadableDetail('branch-filter', array()), $track_only_rules,
phutil_tag('em', array(), pht('Track All Branches'))); phutil_tag('em', array(), pht('Track All Branches')));
$view->addProperty(pht('Track Only'), $track_only); $view->addProperty(pht('Track Only'), $track_only);

View file

@ -68,7 +68,7 @@ final class DiffusionRepositorySubversionManagementPanel
->setViewer($viewer); ->setViewer($viewer);
$default_branch = nonempty( $default_branch = nonempty(
$repository->getHumanReadableDetail('svn-subpath'), $repository->getDetail('svn-subpath'),
phutil_tag('em', array(), pht('Import Entire Repository'))); phutil_tag('em', array(), pht('Import Entire Repository')));
$view->addProperty(pht('Import Only'), $default_branch); $view->addProperty(pht('Import Only'), $default_branch);

View file

@ -239,19 +239,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return idx($this->details, $key, $default); return idx($this->details, $key, $default);
} }
public function getHumanReadableDetail($key, $default = null) {
$value = $this->getDetail($key, $default);
switch ($key) {
case 'branch-filter':
$value = array_keys($value);
$value = implode(', ', $value);
break;
}
return $value;
}
public function setDetail($key, $value) { public function setDetail($key, $value) {
$this->details[$key] = $value; $this->details[$key] = $value;
return $this; return $this;
@ -1211,6 +1198,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return $this; return $this;
} }
public function getTrackOnlyRules() {
return array_keys($this->getDetail('branch-filter', array()));
}
public function setTrackOnlyRules(array $rules) {
$rules = array_fill_keys($rules, true);
$this->setDetail('branch-filter', $rules);
return $this;
}
/* -( Repository URI Management )------------------------------------------ */ /* -( Repository URI Management )------------------------------------------ */

View file

@ -37,11 +37,7 @@ final class PhabricatorRepositoryTestCase
$repo->shouldTrackBranch('imaginary'), $repo->shouldTrackBranch('imaginary'),
pht('Track all branches by default.')); pht('Track all branches by default.'));
$repo->setDetail( $repo->setTrackOnlyRules(array('master'));
'branch-filter',
array(
'master' => true,
));
$this->assertTrue( $this->assertTrue(
$repo->shouldTrackBranch('master'), $repo->shouldTrackBranch('master'),

View file

@ -6,11 +6,11 @@ final class PhabricatorRepositoryTrackOnlyTransaction
const TRANSACTIONTYPE = 'repo:track-only'; const TRANSACTIONTYPE = 'repo:track-only';
public function generateOldValue($object) { public function generateOldValue($object) {
return array_keys($object->getDetail('branch-filter', array())); return $object->getTrackOnlyRules();
} }
public function applyInternalEffects($object, $value) { public function applyInternalEffects($object, $value) {
$object->setDetail('branch-filter', array_fill_keys($value, true)); $object->setTrackOnlyRules($value);
} }
public function getTitle() { public function getTitle() {