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:
parent
c3206476a3
commit
bf6c534b56
6 changed files with 20 additions and 27 deletions
|
@ -212,9 +212,7 @@ final class DiffusionRepositoryEditEngine
|
|||
->setObject($object)
|
||||
->execute();
|
||||
|
||||
$track_value = $object->getDetail('branch-filter', array());
|
||||
$track_value = array_keys($track_value);
|
||||
|
||||
$track_value = $object->getTrackOnlyRules();
|
||||
$autoclose_value = $object->getAutocloseOnlyRules();
|
||||
|
||||
$automation_instructions = pht(
|
||||
|
|
|
@ -23,7 +23,7 @@ final class DiffusionRepositoryBranchesManagementPanel
|
|||
|
||||
$has_any =
|
||||
$repository->getDetail('default-branch') ||
|
||||
$repository->getDetail('branch-filter') ||
|
||||
$repository->getTrackOnlyRules() ||
|
||||
$repository->getAutocloseOnlyRules();
|
||||
|
||||
if ($has_any) {
|
||||
|
@ -74,12 +74,14 @@ final class DiffusionRepositoryBranchesManagementPanel
|
|||
->setViewer($viewer);
|
||||
|
||||
$default_branch = nonempty(
|
||||
$repository->getHumanReadableDetail('default-branch'),
|
||||
$repository->getDetail('default-branch'),
|
||||
phutil_tag('em', array(), $repository->getDefaultBranch()));
|
||||
$view->addProperty(pht('Default Branch'), $default_branch);
|
||||
|
||||
$track_only_rules = $repository->getTrackOnlyRules();
|
||||
$track_only_rules = implode(', ', $track_only_rules);
|
||||
$track_only = nonempty(
|
||||
$repository->getHumanReadableDetail('branch-filter', array()),
|
||||
$track_only_rules,
|
||||
phutil_tag('em', array(), pht('Track All Branches')));
|
||||
$view->addProperty(pht('Track Only'), $track_only);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ final class DiffusionRepositorySubversionManagementPanel
|
|||
->setViewer($viewer);
|
||||
|
||||
$default_branch = nonempty(
|
||||
$repository->getHumanReadableDetail('svn-subpath'),
|
||||
$repository->getDetail('svn-subpath'),
|
||||
phutil_tag('em', array(), pht('Import Entire Repository')));
|
||||
$view->addProperty(pht('Import Only'), $default_branch);
|
||||
|
||||
|
|
|
@ -239,19 +239,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
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) {
|
||||
$this->details[$key] = $value;
|
||||
return $this;
|
||||
|
@ -1211,6 +1198,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
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 )------------------------------------------ */
|
||||
|
||||
|
|
|
@ -37,11 +37,7 @@ final class PhabricatorRepositoryTestCase
|
|||
$repo->shouldTrackBranch('imaginary'),
|
||||
pht('Track all branches by default.'));
|
||||
|
||||
$repo->setDetail(
|
||||
'branch-filter',
|
||||
array(
|
||||
'master' => true,
|
||||
));
|
||||
$repo->setTrackOnlyRules(array('master'));
|
||||
|
||||
$this->assertTrue(
|
||||
$repo->shouldTrackBranch('master'),
|
||||
|
|
|
@ -6,11 +6,11 @@ final class PhabricatorRepositoryTrackOnlyTransaction
|
|||
const TRANSACTIONTYPE = 'repo:track-only';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return array_keys($object->getDetail('branch-filter', array()));
|
||||
return $object->getTrackOnlyRules();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setDetail('branch-filter', array_fill_keys($value, true));
|
||||
$object->setTrackOnlyRules($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
|
|
Loading…
Reference in a new issue