diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2019-02-12 10:49:40 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2019-02-12 10:49:40 -0500 |
commit | 4040fb4f18e1e8d9f164593ee657e65f1326dd44 (patch) | |
tree | 8cd0be8c19beb7bcb9492453f7f736b144f5b0fa | |
parent | a86823b5df8deb6b91973f8b4858885c0883b4e6 (diff) | |
download | korg-helpers-4040fb4f18e1e8d9f164593ee657e65f1326dd44.tar.gz |
Handle cases where refname is tags/foo
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | pr-tracker-bot.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pr-tracker-bot.py b/pr-tracker-bot.py index b58cacb..3c876a6 100755 --- a/pr-tracker-bot.py +++ b/pr-tracker-bot.py @@ -196,20 +196,22 @@ def git_get_commit_id_from_repo_ref(repo, ref): return None logger.debug('getting commit-id from: %s %s', repo, ref) + # Drop the leading "refs/", if any + ref = re.sub(r'^refs/', '', ref) # Is it a full ref name or a shortname? - if ref.find('refs/heads/') < 0 and ref.find('refs/tags/') < 0: + if ref.find('heads/') < 0 and ref.find('tags/') < 0: # Try grabbing it as a head first lines = git_get_command_lines(None, ['ls-remote', repo, 'refs/heads/%s' % ref]) if not lines: # try it as a tag, then lines = git_get_command_lines(None, ['ls-remote', repo, 'refs/tags/%s^{}' % ref]) - elif ref.find('refs/tags/') == 0: - lines = git_get_command_lines(None, ['ls-remote', repo, '%s^{}' % ref]) + elif ref.find('tags/') == 0: + lines = git_get_command_lines(None, ['ls-remote', repo, 'refs/%s^{}' % ref]) else: # Grab it as a head and hope for the best - lines = git_get_command_lines(None, ['ls-remote', repo, ref]) + lines = git_get_command_lines(None, ['ls-remote', repo, 'refs/%s' % ref]) if not lines: # Oh well, we tried @@ -232,7 +234,7 @@ def get_remote_ref_from_body(body): (repo, ref) = chunks else: repo = chunks[0] - ref = 'master' + ref = 'refs/heads/master' break return repo, ref |