From db0459e0569fc92111cfe7a6ec594ec117c51a39 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Fri, 9 May 2014 07:43:25 -0500 Subject: [PATCH] Fix stdout, remote detection, and branch detection --- gerrit-fetch | 14 +++++++------- gerrit-push | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gerrit-fetch b/gerrit-fetch index 1c6e48c..31af43e 100755 --- a/gerrit-fetch +++ b/gerrit-fetch @@ -65,17 +65,17 @@ if len(argv) != 1: change_number = int(argv[0]) cur_dir = os.getcwd() -print "cur_dir=%s" % (cur_dir) +verbose("cur_dir=%s\n" % (cur_dir)) prj_dir = None try: top_dir = get_topdir() except OSError: sys.stderr.write("Cannot find top of android tree\n") sys.exit(1) -print "top_dir=%s" % (top_dir) +verbose("top_dir=%s\n" % (top_dir)) if len(top_dir) < len(cur_dir): prj_dir = cur_dir[len(top_dir)+1:] - print "prj_dir=%s" % (prj_dir) + verbose("prj_dir=%s\n" % (prj_dir)) # Read our manifest args = [] @@ -91,13 +91,13 @@ manifest = ElementTree.fromstring(out) # Figure out which remote to use remote_name = cfg['remote'] if remote_name is None: - if prj_dir is None: - for elem in manifest.findall('default'): - cfg['remote'] = elem.get('name') - else: + if not prj_dir is None: for elem in manifest.findall('project'): if elem.get('path') == prj_dir: remote_name = elem.get('remote') + if remote_name is None: + for elem in manifest.findall('default'): + remote_name = elem.get('remote') if remote_name is None: sys.stderr.write("Cannot find appropriate remote entry in manifest\n"); sys.exit(1); diff --git a/gerrit-push b/gerrit-push index c9e258f..704a098 100755 --- a/gerrit-push +++ b/gerrit-push @@ -80,13 +80,13 @@ manifest = ElementTree.fromstring(out) # Figure out which remote to use remote_name = cfg['remote'] if remote_name is None: - if prj_dir is None: - for elem in manifest.findall('default'): - cfg['remote'] = elem.get('name') - else: + if not prj_dir is None: for elem in manifest.findall('project'): if elem.get('path') == prj_dir: remote_name = elem.get('remote') + if remote_name is None: + for elem in manifest.findall('default'): + remote_name = elem.get('remote') if remote_name is None: sys.stderr.write("Cannot find appropriate remote entry in manifest\n"); sys.exit(1); @@ -125,6 +125,8 @@ if project_branch is None: if project_branch is None: sys.stderr.write("Cannot find project branch in manifest\n"); sys.exit(1); +if project_branch.startswith('refs/heads/'): + project_branch = project_branch[11:] verbose("project_branch=%s\n" % (project_branch)) # Push the change