aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpr-tracker-bot.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/pr-tracker-bot.py b/pr-tracker-bot.py
index 4ee0854..b58cacb 100755
--- a/pr-tracker-bot.py
+++ b/pr-tracker-bot.py
@@ -196,14 +196,25 @@ def git_get_commit_id_from_repo_ref(repo, ref):
return None
logger.debug('getting commit-id from: %s %s', repo, ref)
- lines = git_get_command_lines(None, ['ls-remote', repo, '%s^{}' % ref])
- if not lines:
- # Try it as a head
- lines = git_get_command_lines(None, ['ls-remote', repo, ref])
+ # Is it a full ref name or a shortname?
+ if ref.find('refs/heads/') < 0 and ref.find('refs/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:
- # Oh well, we tried
- logger.debug('did not find commit-id, ignoring pull request')
- return None
+ # 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])
+
+ else:
+ # Grab it as a head and hope for the best
+ lines = git_get_command_lines(None, ['ls-remote', repo, ref])
+
+ if not lines:
+ # Oh well, we tried
+ logger.debug('did not find commit-id, ignoring pull request')
+ return None
commit_id = lines[0].split()[0]
logger.debug('success, commit-id: %s', commit_id)