Repository: incubator-impala Updated Branches: refs/heads/master bf27c542b -> 45ff0f9e6
IMPALA-3225: Fix and update push_to_asf.py to match the new Impala-ASF project The script now points to the updated 'Impala-ASF' repo on Gerrit. Some fixes were also made to the error messages and how we handle remotes. Now we have the following options: '--gerrit_remote' to set any gerrit remote name of the committers choice. '--apache_remote' also lets any remote name to point to the Apache git repo. The Gerrit URL is now hardcoded and no longer an option because the Gerrit project name has been decided and is unlikely to change. This is a follow up commit to other commits with the same JIRA ID. Change-Id: Ieac2c2715ced99fd0ff3e3c1422187d5d1eef3d9 Reviewed-on: http://gerrit.cloudera.org:8080/3759 Reviewed-by: Jim Apple <[email protected]> Reviewed-by: Sailesh Mukil <[email protected]> Tested-by: Sailesh Mukil <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/fbed1c97 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/fbed1c97 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/fbed1c97 Branch: refs/heads/master Commit: fbed1c9789c1bee5cb82aacda5f42bb30a44b924 Parents: bf27c54 Author: Sailesh Mukil <[email protected]> Authored: Mon Jul 25 11:33:18 2016 -0700 Committer: Sailesh Mukil <[email protected]> Committed: Mon Jul 25 22:15:53 2016 +0000 ---------------------------------------------------------------------- bin/push_to_asf.py | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/fbed1c97/bin/push_to_asf.py ---------------------------------------------------------------------- diff --git a/bin/push_to_asf.py b/bin/push_to_asf.py index 0b76a27..5865fb8 100755 --- a/bin/push_to_asf.py +++ b/bin/push_to_asf.py @@ -43,6 +43,7 @@ import subprocess import sys APACHE_REPO = "https://git-wip-us.apache.org/repos/asf/incubator-impala.git" +GERRIT_URL_RE = re.compile(r"ssh://[email protected]:29418/Impala-ASF") # Parsed options, filled in by main(). OPTIONS = None @@ -106,18 +107,20 @@ def get_my_email(): def check_apache_remote(): """ - Checks that there is a remote named 'apache' set up correctly. + Checks that there is a remote named <OPTIONS.apache_remote> set up correctly. Otherwise, exits with an error message. """ try: url = check_output(\ - ['git', 'config', '--local', '--get', 'remote.apache.url']).strip() + ['git', 'config', '--local', '--get', + 'remote.' + OPTIONS.apache_remote + '.url']).strip() except subprocess.CalledProcessError: - print >>sys.stderr, "No remote named 'apache'. Please set one up, for example with: " + print >>sys.stderr, "No remote named " + OPTIONS.apache_remote + \ + ". Please set one up, for example with: " print >>sys.stderr, " git remote add apache", APACHE_REPO sys.exit(1) if url != APACHE_REPO: - print >>sys.stderr, "Unexpected URL for remote 'apache'." + print >>sys.stderr, "Unexpected URL for remote " + OPTIONS.apache_remote + "." print >>sys.stderr, " Got: ", url print >>sys.stderr, " Expected:", APACHE_REPO sys.exit(1) @@ -125,19 +128,20 @@ def check_apache_remote(): def check_gerrit_remote(): """ - Checks that there is a remote named 'gerrit' set up correctly. + Checks that there is a remote named <OPTIONS.gerrit_remote> set up correctly. Otherwise, exits with an error message. """ try: url = check_output(['git', 'config', '--local', '--get', - 'remote.' + OPTIONS.remote + '.url']).strip() + 'remote.' + OPTIONS.gerrit_remote + '.url']).strip() except subprocess.CalledProcessError: - print >>sys.stderr, "No remote named 'gerrit'. Please set one up following " + print >>sys.stderr, "No remote named " + OPTIONS.gerrit_remote + \ + ". Please set one up following " print >>sys.stderr, "the contributor guide." sys.exit(1) - gerrit_url_re = re.compile(OPTIONS.gerrit) - if not gerrit_url_re.match(url): - print >>sys.stderr, "Unexpected URL for remote 'gerrit'." + + if not GERRIT_URL_RE.match(url): + print >>sys.stderr, "Unexpected URL for remote " + OPTIONS.gerrit_remote print >>sys.stderr, " Got: ", url print >>sys.stderr, " Expected to find host '%s' in the URL" % GERRIT_HOST sys.exit(1) @@ -263,13 +267,17 @@ def main(): p.add_option("-n", "--dry-run", action="store_true", help="Perform git pushes with --dry-run") p.add_option( - "-r", - "--remote", - dest="remote", + "-g", + "--gerrit_remote", + dest="gerrit_remote", help="Name of the git remote that corresponds to gerrit", default="asf-gerrit") - p.add_option("-g", "--gerrit", dest="gerrit", help="Gerrit URL regex", - default=r"ssh://[email protected]:29418/ImpalaASF") + p.add_option( + "-a", + "--apache_remote", + dest="apache_remote", + help="Name of the git remote that corresponds to apache", + default="apache") OPTIONS, args = p.parse_args() if args: p.error("no arguments expected") @@ -280,13 +288,13 @@ def main(): check_gerrit_remote() # Ensure we have the latest state of gerrit. - fetch('gerrit') + fetch(OPTIONS.gerrit_remote) # Check the current state of branches on Apache. # For each branch, we try to update it if the revisions don't match. - apache_branches = get_branches('apache') + apache_branches = get_branches(OPTIONS.apache_remote) for branch, apache_sha in sorted(apache_branches.iteritems()): - gerrit_sha = rev_parse("remotes/gerrit/" + branch) + gerrit_sha = rev_parse("remotes/" + OPTIONS.gerrit_remote + "/" + branch) print "Branch '%s':\t" % branch, if gerrit_sha is None: print Colors.YELLOW, "found on Apache but not in gerrit", Colors.RESET
