diff options
author | David Trowbridge <trowbrds@gmail.com> | 2010-02-06 11:54:31 -0800 |
---|---|---|
committer | David Trowbridge <trowbrds@gmail.com> | 2010-02-06 11:54:31 -0800 |
commit | 9137e9e7a9eab2c7811d952997b0723bf7746010 (patch) | |
tree | 708b1321cfd90d0e1605510e37cd2e28f04722f6 | |
parent | 8a7c87eae5da07831437c54378eab4da6a41a992 (diff) |
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/
-rwxr-xr-x | rbtools/postreview.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/rbtools/postreview.py b/rbtools/postreview.py index eeb96ef..3022726 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -2075,34 +2075,32 @@ class GitClient(SCMClient): 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): """ |