mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
When arc
has sent target branch data up after D14736, use it in the UI and "Land Revision"
Summary: Ref T9952. Ref T3462. After D14736, if we have information about the target/"onto" branch, use it in the UI: - Show "feature (branched from master)" instead of "feature". - Default "Land Revision" to hit the correct branch. Test Plan: - Branched from `test` with branch tracking. - Diffed. - Saw "feature (branched from test)" in UI. - Saw "test" fill as default in "Land Revision", despite the repository having a different default branch. {F1020587} {F1020588} Reviewers: chad Reviewed By: chad Maniphest Tasks: T3462, T9952 Differential Revision: https://secure.phabricator.com/D14737
This commit is contained in:
parent
f60548d081
commit
954cd4b1b6
3 changed files with 66 additions and 5 deletions
|
@ -30,7 +30,7 @@ final class DifferentialRevisionOperationController
|
|||
$diff = $revision->getActiveDiff();
|
||||
$repository = $revision->getRepository();
|
||||
|
||||
$default_ref = $this->loadDefaultRef($repository);
|
||||
$default_ref = $this->loadDefaultRef($repository, $diff);
|
||||
|
||||
if ($default_ref) {
|
||||
$v_ref = array($default_ref->getPHID());
|
||||
|
@ -133,8 +133,10 @@ final class DifferentialRevisionOperationController
|
|||
);
|
||||
}
|
||||
|
||||
private function loadDefaultRef(PhabricatorRepository $repository) {
|
||||
$default_name = $this->getDefaultRefName($repository);
|
||||
private function loadDefaultRef(
|
||||
PhabricatorRepository $repository,
|
||||
DifferentialDiff $diff) {
|
||||
$default_name = $this->getDefaultRefName($repository, $diff);
|
||||
|
||||
if (!strlen($default_name)) {
|
||||
return null;
|
||||
|
@ -145,7 +147,15 @@ final class DifferentialRevisionOperationController
|
|||
->executeOne();
|
||||
}
|
||||
|
||||
private function getDefaultRefName(PhabricatorRepository $repository) {
|
||||
private function getDefaultRefName(
|
||||
PhabricatorRepository $repository,
|
||||
DifferentialDiff $diff) {
|
||||
|
||||
$onto = $diff->loadTargetBranch();
|
||||
if ($onto !== null) {
|
||||
return $onto;
|
||||
}
|
||||
|
||||
return $repository->getDefaultBranch();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,15 @@ final class DifferentialBranchField
|
|||
} else if (strlen($bookmark)) {
|
||||
return pht('%s (bookmark)', $bookmark);
|
||||
} else if (strlen($branch)) {
|
||||
return $branch;
|
||||
$onto = $diff->loadTargetBranch();
|
||||
if (strlen($onto)) {
|
||||
return pht(
|
||||
'%s (branched from %s)',
|
||||
$branch,
|
||||
$onto);
|
||||
} else {
|
||||
return $branch;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -489,6 +489,49 @@ final class DifferentialDiff
|
|||
return 'refs/tags/phabricator/diff/'.$this->getID();
|
||||
}
|
||||
|
||||
public function loadTargetBranch() {
|
||||
// TODO: This is sketchy, but just eat the query cost until this can get
|
||||
// cleaned up.
|
||||
|
||||
// For now, we're only returning a target if there's exactly one and it's
|
||||
// a branch, since we don't support landing to more esoteric targets like
|
||||
// tags yet.
|
||||
|
||||
$property = id(new DifferentialDiffProperty())->loadOneWhere(
|
||||
'diffID = %d AND name = %s',
|
||||
$this->getID(),
|
||||
'arc:onto');
|
||||
if (!$property) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $property->getData();
|
||||
|
||||
if (!$data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (count($data) != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$onto = head($data);
|
||||
if (!is_array($onto)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$type = idx($onto, 'type');
|
||||
if ($type != 'branch') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return idx($onto, 'name');
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue