mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 10:12:41 +01:00
Examine upstream path instead of assuming "origin"
Summary: Instead of blindly assuming that "origin" is the repository that arcanist should communicate with, use the remote that is configured for the branch in git. Test Plan: Used `arc which` with a branch with no upstream, an origin/master upstream, and an upstream/master upstream -- the last of which is being used to create and land this diff. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: joshuaspence, Korvin Differential Revision: https://secure.phabricator.com/D14530
This commit is contained in:
parent
b32149495b
commit
e730ececbc
1 changed files with 12 additions and 2 deletions
|
@ -521,6 +521,16 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRemoteURI() {
|
public function getRemoteURI() {
|
||||||
|
// Determine which remote to examine; default to 'origin'
|
||||||
|
$remote = 'origin';
|
||||||
|
$branch = $this->getBranchName();
|
||||||
|
if ($branch) {
|
||||||
|
$path = $this->getPathToUpstream($branch);
|
||||||
|
if ($path->isConnectedToRemote()) {
|
||||||
|
$remote = $path->getRemoteRemoteName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// "git ls-remote --get-url" is the appropriate plumbing to get the remote
|
// "git ls-remote --get-url" is the appropriate plumbing to get the remote
|
||||||
// URI. "git config remote.origin.url", on the other hand, may not be as
|
// URI. "git config remote.origin.url", on the other hand, may not be as
|
||||||
// accurate (for example, it does not take into account possible URL
|
// accurate (for example, it does not take into account possible URL
|
||||||
|
@ -528,9 +538,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
// the --get-url flag requires git 1.7.5.
|
// the --get-url flag requires git 1.7.5.
|
||||||
$version = $this->getGitVersion();
|
$version = $this->getGitVersion();
|
||||||
if (version_compare($version, '1.7.5', '>=')) {
|
if (version_compare($version, '1.7.5', '>=')) {
|
||||||
list($stdout) = $this->execxLocal('ls-remote --get-url origin');
|
list($stdout) = $this->execxLocal('ls-remote --get-url %s', $remote);
|
||||||
} else {
|
} else {
|
||||||
list($stdout) = $this->execxLocal('config remote.origin.url');
|
list($stdout) = $this->execxLocal('config %s', "remote.$remote.url");
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = rtrim($stdout);
|
$uri = rtrim($stdout);
|
||||||
|
|
Loading…
Reference in a new issue