git integration: Fix handling of new/removed branches.

(imported from commit f87ba78dbc292a05d82aedc74a90de6cbefee3e2)
This commit is contained in:
Tim Abbott 2013-02-19 13:17:48 -05:00
parent 4155e1e918
commit 28ebf108a9

View file

@ -88,12 +88,23 @@ def send_bot_message(oldrev, newrev, refname):
# Don't forward the notice anywhere
return
new_head = newrev[:12]
old_head = oldrev[:12]
if (oldrev == '0000000000000000000000000000000000000000' or
newrev == '0000000000000000000000000000000000000000'):
# New branch pushed or old branch removed
added = ''
removed = ''
else:
added = git_commit_range(oldrev, newrev)
removed = git_commit_range(newrev, oldrev)
new_head = newrev[:12]
if removed:
if oldrev == '0000000000000000000000000000000000000000':
message = '`%s` was pushed to new branch `%s`' % (new_head, branch)
elif newrev == '0000000000000000000000000000000000000000':
message = 'branch `%s` was removed (was `%s`)' % (branch, old_head)
elif removed:
message = '`%s` was pushed to `%s`, **REMOVING**:\n\n%s' % (new_head, branch, removed)
if added:
message += '\n**and adding**:\n\n' + added