def main(): addr_params = XMLRPC_ADDR + (PROJECT_TOKEN, ) bot = ServerProxy('http://%s:%i/%s/xmlrpc' % addr_params) repo = os.path.basename(os.getcwd()) if repo.endswith('.git'): repo = repo[:-len('.git')] messages = [] for line in sys.stdin: (old, new, refname) = line.split() if refname.startswith('refs/heads/'): refname = refname[len('refs/heads/'):] if new.strip('0'): if old.strip('0'): revisions = get_output('git', 'rev-list', '%s..%s' % (old, new)).splitlines() for revision in reversed(revisions): msg = format_commit_message(repo, refname, revision) messages.append(msg) else: messages.append('New branch: %s/%s' % (repo, refname)) messages.append( format_commit_message(repo, refname, new)) else: messages.append( 'Branch %s/%s deleted (was: %s)' % (repo, refname, old)) if messages: bot.notify("\n".join(messages))