From 9137e9e7a9eab2c7811d952997b0723bf7746010 Mon Sep 17 00:00:00 2001 From: David Trowbridge Date: Sat, 6 Feb 2010 11:54:31 -0800 Subject: Do not run git remote show just because of remote URL. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/ --- rbtools/postreview.py | 24 +++++++++++------------- 1 file 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): """ -- cgit v1.2.3