From 7f46f55d67c50f50dc51a00d2487250c4c1e5e94 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Wed, 4 Jan 2017 00:27:19 +0200 Subject: Note when a push is forced --- local/handler/PushHandler.py | 16 ++++------------ local/theme/DefaultTheme.py | 5 +++-- local/utility.py | 7 ++++--- 3 files changed, 11 insertions(+), 17 deletions(-) (limited to 'local') diff --git a/local/handler/PushHandler.py b/local/handler/PushHandler.py index e40aa64..13052a3 100644 --- a/local/handler/PushHandler.py +++ b/local/handler/PushHandler.py @@ -29,17 +29,6 @@ def handle(data, theme): action = "re-tagged" else: action = "re-created" - elif data['created'] and not data['forced']: - if isTag: - action = "tagged" - else: - action = "created" - elif data['deleted'] and not data['forced']: - if isTag: - action = "deleted tag" - else: - action = "deleted" - urls = '' elif data['created']: if isTag: action = "tagged" @@ -62,9 +51,12 @@ def handle(data, theme): branch = branch, actor = data['pusher']['name'], url = getShortURL(data['compare']), - count = commitno + count = commitno, + forced = data['forced'] ) elif branched: + action = "force %s" % (action,) + if isTag: theme.tag( actor = data['pusher']['name'], diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py index 3442383..96259d0 100644 --- a/local/theme/DefaultTheme.py +++ b/local/theme/DefaultTheme.py @@ -3,10 +3,11 @@ from Theme import Theme from ..utility import * class DefaultTheme(Theme): - def push(self, branch, actor, count, url): - self.msgs.append( "%s: %s pushed %s %s %s%s" % ( + def push(self, branch, actor, count, forced, url): + self.msgs.append( "%s: %s %s %s %s %s%s" % ( self.repo(branch), ircutils.mircColor(actor, "green"), + colorAction("force pushed") if forced else "pushed", ircutils.bold(str(count)), plural(count, "commit", "commits"), self.enclose(url), diff --git a/local/utility.py b/local/utility.py index 59dfd91..321637e 100644 --- a/local/utility.py +++ b/local/utility.py @@ -76,7 +76,7 @@ def maxLen(msg, maxn=400, splitLines=True): if splitLines is True: lines = msg.splitlines() - line = lines[0] + line = lines[0] if lines else "" else: line = msg @@ -90,6 +90,7 @@ def maxLen(msg, maxn=400, splitLines=True): def colorAction(action): """Give an action string (e.g. created, edited) and get a nice IRC colouring""" + if action in [ "created", "opened", "tagged", "success", "passed", "fixed", "published", "completed" ]: return ircutils.bold(ircutils.mircColor(action, "green")) @@ -101,8 +102,8 @@ def colorAction(action): return ircutils.bold(ircutils.mircColor(action, "light blue")) if action in [ "reopened", "pending" ]: return ircutils.bold(ircutils.mircColor(action, "blue")) - if action in [ "forced the creation of", "forced the deletion of" ]: - return ircutils.bold(ircutils.mircColor(action,"brown")) + if action[0:5] in [ "force" ]: + return ircutils.bold(ircutils.mircColor(action, "brown")) return action def getShortURL(longurl): -- cgit v1.2.3