Retrieve remote pushurl independently of user's locale

git-review tried to parse the output of "git remote show -n" to
retrieve a remote's pushurl and failed if the user's locale was not
English.  This change reads the configuration directly instead.

Change-Id: Idbf98ae00538dd611277ca862da969f22cbe6265
Closes-Bug: #1177429
This commit is contained in:
Tim Landscheidt
2013-12-27 19:31:04 +00:00
committed by Cedric Brandily
parent 9a7f8ad613
commit cc28fb6969

View File

@@ -224,7 +224,7 @@ def set_hooks_commit_msg(remote, target_file):
os.mkdir(hooks_dir) os.mkdir(hooks_dir)
(hostname, username, port, project_name) = \ (hostname, username, port, project_name) = \
parse_git_show(remote, "Push") get_ssh_remote_url(remote)
if not os.path.exists(target_file) or UPDATE: if not os.path.exists(target_file) or UPDATE:
if VERBOSE: if VERBOSE:
@@ -322,13 +322,11 @@ def add_remote(hostname, port, project, remote):
print() print()
def parse_git_show(remote, verb): def get_ssh_remote_url(remote):
fetch_url = "" url = git_config_get_value('remote.%s' % remote, 'url', '')
for line in run_command("git remote show -n %s" % remote).split("\n"): push_url = git_config_get_value('remote.%s' % remote, 'pushurl', url)
if line.strip().startswith("%s" % verb):
fetch_url = line.split()[2]
parsed_url = urlparse(fetch_url) parsed_url = urlparse(push_url)
project_name = parsed_url.path.lstrip("/") project_name = parsed_url.path.lstrip("/")
if project_name.endswith(".git"): if project_name.endswith(".git"):
project_name = project_name[:-4] project_name = project_name[:-4]
@@ -338,7 +336,7 @@ def parse_git_show(remote, verb):
port = parsed_url.port port = parsed_url.port
if VERBOSE: if VERBOSE:
print("Found origin %s URL:" % verb, fetch_url) print("Found origin Push URL:", push_url)
# Workaround bug in urlparse on OSX # Workaround bug in urlparse on OSX
if parsed_url.scheme == "ssh" and parsed_url.path[:2] == "//": if parsed_url.scheme == "ssh" and parsed_url.path[:2] == "//":
@@ -622,7 +620,7 @@ class CannotParseOpenChangesets(ChangeSetException):
def list_reviews(remote): def list_reviews(remote):
(hostname, username, port, project_name) = \ (hostname, username, port, project_name) = \
parse_git_show(remote, "Push") get_ssh_remote_url(remote)
if port is not None: if port is not None:
port = "-p %s" % port port = "-p %s" % port
@@ -747,7 +745,7 @@ class ResetHardFailed(CommandFailed):
def fetch_review(review, masterbranch, remote): def fetch_review(review, masterbranch, remote):
(hostname, username, port, project_name) = \ (hostname, username, port, project_name) = \
parse_git_show(remote, "Push") get_ssh_remote_url(remote)
if port is not None: if port is not None:
port = "-p %s" % port port = "-p %s" % port