1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 23:02:41 +01:00

Avoid parsing git "remote show" using "ls-remote"

Summary:
Ref T5554. This makes git remote URL detection locale-agnostic.

The previously suggested `git config remote.origin.url` command does
almost the same, but does not support the URL rewriting features in
git-config (`url.<base>.insteadOf`).

This one does, although it has the unintuitive behavior of just printing
the passed remote name when the remote does not exist, or even when
called outside a git repo.

Test Plan:
* Switched to non-english locale in which git has a translation.
* Ran `arc which` on the Arcanist repo. It could not determine the remote URI.
* Applied patch, `arc which` found the URI.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: johnny-bit, Korvin

Maniphest Tasks: T5554

Differential Revision: https://secure.phabricator.com/D13983
This commit is contained in:
Javier Arteaga 2015-08-24 04:51:03 -07:00 committed by epriestley
parent 9b8c9d280e
commit 6ecb3fb87d

View file

@ -501,14 +501,14 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
} }
public function getRemoteURI() { public function getRemoteURI() {
list($stdout) = $this->execxLocal('remote show -n origin'); list($stdout) = $this->execxLocal('ls-remote --get-url origin');
$matches = null; $uri = rtrim($stdout);
if (preg_match('/^\s*Fetch URL: (.*)$/m', $stdout, $matches)) { if ($uri === 'origin') {
return trim($matches[1]); return null;
} }
return null; return $uri;
} }
public function getSourceControlPath() { public function getSourceControlPath() {