mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
In "arc land", when "remote/onto" does not exist locally, try to fetch it before giving up
Summary: Fixes T10650. It's valid to `arc land --remote origin --onto master` without first fetching that ref. If we can't find a local ref for a specified remote branch, try to fetch it before giving up. (In the long run, this should be valid even if the remote branch does not exist at all and the user intends to create it -- see T12876 -- but this is a step toward that.) Test Plan: - Ran `rm .git/refs/remotes/origin/master`, then landed into "master". - Before: "arc land" bailed out immediately. - After: "arc land" fetches the missing ref. ``` $ arc land TARGET Landing onto "master", the default target under git. REMOTE Using remote "origin", the default remote under Git. TARGET No local ref exists for branch "master" in remote "origin", attempting fetch... FETCHED Fetched branch "master" from remote "origin". ... ``` Maniphest Tasks: T10650 Differential Revision: https://secure.phabricator.com/D20870
This commit is contained in:
parent
a76054f8d6
commit
7383c2f4e6
1 changed files with 27 additions and 2 deletions
|
@ -139,9 +139,34 @@ final class ArcanistGitLandEngine
|
|||
$this->getTargetFullRef());
|
||||
|
||||
if ($err) {
|
||||
throw new Exception(
|
||||
$this->writeWarn(
|
||||
pht('TARGET'),
|
||||
pht(
|
||||
'Branch "%s" does not exist in remote "%s".',
|
||||
'No local ref exists for branch "%s" in remote "%s", attempting '.
|
||||
'fetch...',
|
||||
$this->getTargetOnto(),
|
||||
$this->getTargetRemote()));
|
||||
|
||||
$api->execManualLocal(
|
||||
'fetch %s %s --',
|
||||
$this->getTargetRemote(),
|
||||
$this->getTargetOnto());
|
||||
|
||||
list($err) = $api->execManualLocal(
|
||||
'rev-parse --verify %s',
|
||||
$this->getTargetFullRef());
|
||||
if ($err) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Branch "%s" does not exist in remote "%s".',
|
||||
$this->getTargetOnto(),
|
||||
$this->getTargetRemote()));
|
||||
}
|
||||
|
||||
$this->writeInfo(
|
||||
pht('FETCHED'),
|
||||
pht(
|
||||
'Fetched branch "%s" from remote "%s".',
|
||||
$this->getTargetOnto(),
|
||||
$this->getTargetRemote()));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue