HBASE-20106 [api compliance chacker] Fix Bug Where Branch Isn't Found

While git rev-parse, sometimes the branch cannot be found unless
the remote is specified. This fix tries to use "origin" if the
remote is not specified and the branch is not found.

Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
Alex Leblang 2017-09-07 12:31:53 -04:00 committed by Sean Busbey
parent f71c00c02e
commit 2f3632a2a4
1 changed files with 6 additions and 1 deletions

View File

@ -116,7 +116,12 @@ def checkout_java_tree(rev, path):
def get_git_hash(revname):
""" Convert 'revname' to its SHA-1 hash. """
return check_output(["git", "rev-parse", revname],
try:
return check_output(["git", "rev-parse", revname],
cwd=get_repo_dir()).strip()
except:
revname = "origin/" + revname
return check_output(["git", "rev-parse", revname],
cwd=get_repo_dir()).strip()