mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 02:02:40 +01:00
Use GIT tracked branches for arc land targets when reasonable
Summary: See T5690. -arc land now respects tracked branch when choosing 'onto'; '--onto' option remains as an override. -arc land now respects tracked branch when choosing a remote; the remote is taken from 'onto's upstream unless the '--remote' option is present; when 'onto' branch has no upstream the '--remote' option must be provided as before. Since 'arc feature' branches are (already) created as tracking branches, 'arc.land.onto.default' if present, is only used as the default when a non-tracking branch created by some other means is landed with out explicit '--onto'. This may be surprising but is probably the correct go-forward behavior and is inline with the description in T5690. Test Plan: -checked having no arc.land.onto.default still assumes 'master' -checked 'arc.land.onto.default' still overrides 'master' -checked upstream branch (of feature branch) overrides 'master' and 'arc.land.onto.default' -checked '--onto' overrides all -checked origin is default for non-tracking branches -checked the land onto branch's upstream remote is used instead of 'origin' -checked '--remote' overrides 'origin' and the tracked upstream -tested several crazy branch names including 'something/like/this' for both the upstream and tracking branches -tested on linux and OS X -rinse and repeat on Windows Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5690 Differential Revision: https://secure.phabricator.com/D10058
This commit is contained in:
parent
76d80faddf
commit
bb6d11b732
1 changed files with 22 additions and 0 deletions
|
@ -218,6 +218,22 @@ EOTEXT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getUpstreamMatching($branch, $pattern) {
|
||||||
|
if ($this->isGit) {
|
||||||
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
list($err, $fullname) = $repository_api->execManualLocal(
|
||||||
|
'rev-parse --symbolic-full-name %s@{upstream}',
|
||||||
|
$branch);
|
||||||
|
if (!$err) {
|
||||||
|
$matches = null;
|
||||||
|
if (preg_match($pattern, $fullname, $matches)) {
|
||||||
|
return last($matches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private function readArguments() {
|
private function readArguments() {
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
$this->isGit = $repository_api instanceof ArcanistGitAPI;
|
$this->isGit = $repository_api instanceof ArcanistGitAPI;
|
||||||
|
@ -275,10 +291,16 @@ EOTEXT
|
||||||
$onto_default = nonempty(
|
$onto_default = nonempty(
|
||||||
$this->getConfigFromAnySource('arc.land.onto.default'),
|
$this->getConfigFromAnySource('arc.land.onto.default'),
|
||||||
$onto_default);
|
$onto_default);
|
||||||
|
$onto_default = coalesce(
|
||||||
|
$this->getUpstreamMatching($this->branch, '/^refs\/heads\/(.+)$/'),
|
||||||
|
$onto_default);
|
||||||
$this->onto = $this->getArgument('onto', $onto_default);
|
$this->onto = $this->getArgument('onto', $onto_default);
|
||||||
$this->ontoType = $this->getBranchType($this->onto);
|
$this->ontoType = $this->getBranchType($this->onto);
|
||||||
|
|
||||||
$remote_default = $this->isGit ? 'origin' : '';
|
$remote_default = $this->isGit ? 'origin' : '';
|
||||||
|
$remote_default = coalesce(
|
||||||
|
$this->getUpstreamMatching($this->onto, '/^refs\/remotes\/(.+?)\//'),
|
||||||
|
$remote_default);
|
||||||
$this->remote = $this->getArgument('remote', $remote_default);
|
$this->remote = $this->getArgument('remote', $remote_default);
|
||||||
|
|
||||||
if ($this->getArgument('merge')) {
|
if ($this->getArgument('merge')) {
|
||||||
|
|
Loading…
Reference in a new issue