From 20056690507c2a69bfdb307ae5ade414dac5a795 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Mon, 13 Nov 2017 01:26:35 +0200 Subject: Improve issues theme Closes #10 Closes #11 --- local/theme/DefaultTheme.py | 18 +++++++++++++++--- local/utility.py | 9 +++++---- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'local') diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py index d9ee11a..dbb8128 100644 --- a/local/theme/DefaultTheme.py +++ b/local/theme/DefaultTheme.py @@ -83,18 +83,30 @@ class DefaultTheme(Theme): formattedActor = ircutils.bold(formattedActor) extra = '' + formattedFiller = type if action == 'assigned': - extra = " to %s" % ircutils.bold(ircutils.mircColor(assignee, "green")) + if assignee == actor: + # Don't show assignee name twice + action = 'self-assigned' + else: + extra = " to %s" % ircutils.bold(ircutils.mircColor(assignee, "green")) elif action == 'unassigned': extra = " from %s" % ircutils.mircColor(assignee, "green") - elif action == 'labeled' or action == 'unlabeled': + elif action == 'labeled': + # This is not the same syntax as 'unlabeled', since adding a label + # is a more frequent action than removing one, and adding more + # filler text would make the message harder to read extra = " as %s" % ircutils.mircColor(labelName, hexToMirc(labelColor)) + elif action == 'unlabeled': + # Grammar gets weird here + action = 'removed' + formattedFiller = "%s label from" % ircutils.mircColor(labelName, hexToMirc(labelColor)) self.msgs.append( "%s: %s %s %s #%s%s%s%s %s%s" % ( self.repo(), formattedActor, colorAction(action), - type, + formattedFiller, issueNo, " \"%s\"" % (ircutils.bold(issueTitle)) if showName else '', " by %s" % ircutils.mircColor(creator,"green") if creator != actor else '', diff --git a/local/utility.py b/local/utility.py index 86e1b91..0393ae7 100644 --- a/local/utility.py +++ b/local/utility.py @@ -100,9 +100,9 @@ def maxLen(msg, maxn=400, splitLines=True): ret = msg return ret - +# TODO: Use a better data structure for this? def colorAction(action): - """Give an action string (e.g. created, edited) and get a nice IRC colouring""" + """Give an action string (e.g. created, edited) and get a nice IRC colouring.""" # Fix past tense for some github verbs if action in ["synchronize"]: @@ -113,9 +113,10 @@ def colorAction(action): return ircutils.bold(ircutils.mircColor(action, "green")) if action in ["deleted", "closed", "re-tagged", "deleted tag", "failed", "errored", "failure", "still failing", - "broken", "error"]: + "broken", "error", "removed"]: return ircutils.bold(ircutils.mircColor(action, "red")) - if action in ["assigned", "merged", "synchronized"]: + if action in ["assigned", "self-assigned", "merged", "synchronized", + "labeled"]: return ircutils.bold(ircutils.mircColor(action, "light blue")) if action in ["reopened", "pending"]: return ircutils.bold(ircutils.mircColor(action, "blue")) -- cgit v1.2.3