From 1f54970da256d1a868e8bb960baf0c319f173214 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Thu, 1 Aug 2013 13:05:37 +0300 Subject: Add support for branch creation and deletion messages --- plugin.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index 08bc78c..e063431 100644 --- a/plugin.py +++ b/plugin.py @@ -59,6 +59,8 @@ def colorAction(action): return ircutils.bold(ircutils.mircColor(action, "light blue")) if action == "reopened": return ircutils.bold(ircutils.mircColor(action, "blue")) + if action == "forced the creation of" or action == "forced the deletion of": + return ircutils.bold(ircutils.mircColor(action,"brown")) return action def registryValue(plugin, name, channel=None, value=True): @@ -168,7 +170,24 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): commitno = len(data['commits']) branch = data['ref'].split('/',2)[2] - if configValue("hidePush",None) is False: + branched = data['created'] or data['deleted'] + branchFrom = '' + if branched: + if 'base_ref' in data: + branchFrom = ' by %s' % (data['base_ref'].split('/',2)[2],) + if data['created'] and not data['forced']: + action = "created" + elif data['deleted'] and not data['forced']: + action = "deleted" + elif data['created']: + action = "created" + elif data['deleted']: + action = "deleted" + else: + action = "did something with" + + + if configValue("hidePush",None) == False and not branched: msgs.append( ircmsgs.privmsg(channel, "%s @ %s: %s pushed %s %s (%s):" % ( ircutils.bold(ircutils.mircColor(branch, "blue")), ircutils.bold(data['repository']['name']), @@ -177,6 +196,15 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): plural(commitno, "commit", "commits"), getShortURL(data['compare']) )) ) + elif branched: + msgs.append( ircmsgs.privmsg(channel, "%s: %s %s branch %s%s (%s):" % ( + ircutils.bold(data['repository']['name']), + ircutils.mircColor(data['pusher']['name'], "green"), + colorAction(action), + ircutils.bold(ircutils.mircColor(branch, "blue")), + branchFrom, + getShortURL(data['compare']) + )) ) for commit in data['commits']: if 'username' in commit['author']: -- cgit v1.2.3