Permalink
Browse files

Do not run git remote show just because of remote URL.

Patch from Petr Novák. Current post-review's GitClient calls "git remote show"
to determine URL of upstream repository and parses its output. This patch
replaces this with fetching the URL from local configuration, which spares a few
moments of time since "git remote show" has to communicate with the remote in
order to determine list of remote branches (which is subsequently discarded by
the script).

Testing done:
Tested locally, seems to work fine. (I used it to submit this review request).

Reviewed at http://reviews.reviewboard.org/r/1377/
  • Loading branch information...
1 parent 8a7c87e commit 9137e9e7a9eab2c7811d952997b0723bf7746010 @davidt davidt committed Feb 6, 2010
Showing with 11 additions and 13 deletions.
  1. +11 −13 rbtools/postreview.py
View
@@ -2075,34 +2075,32 @@ def get_repository_info(self):
if remote and remote != '.' and merge:
self.upstream_branch = '%s/%s' % (remote, merge)
- self.upstream_branch, origin = self.get_origin(self.upstream_branch,
+ self.upstream_branch, origin_url = self.get_origin(self.upstream_branch,
True)
- if origin.startswith("fatal:"):
- self.upstream_branch, origin = self.get_origin()
+ if not origin_url or origin_url.startswith("fatal:"):
+ self.upstream_branch, origin_url = self.get_origin()
- m = re.search(r'URL: (.+)', origin)
- if m:
- url = m.group(1).rstrip('/')
- if url:
- self.type = "git"
- return RepositoryInfo(path=url, base_path='',
- supports_parent_diffs=True)
+ url = origin_url.rstrip('/')
+ if url:
+ self.type = "git"
+ return RepositoryInfo(path=url, base_path='',
+ supports_parent_diffs=True)
return None
def get_origin(self, default_upstream_branch=None, ignore_errors=False):
"""Get upstream remote origin from options or parameters.
- Returns a tuple: (upstream_branch, remote)
+ Returns a tuple: (upstream_branch, remote_url)
"""
upstream_branch = options.tracking or default_upstream_branch or \
'origin/master'
upstream_remote = upstream_branch.split('/')[0]
- origin = execute(["git", "remote", "show", upstream_remote],
+ origin_url = execute(["git", "config", "remote.%s.url" % upstream_remote],
ignore_errors=ignore_errors)
- return (upstream_branch, origin)
+ return (upstream_branch, origin_url.rstrip('\n'))
def is_valid_version(self, actual, expected):
"""

0 comments on commit 9137e9e

Please sign in to comment.