From e350d277690773bf0cca5da00718a73262d69149 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Thu, 18 May 2017 03:20:12 +0300 Subject: Add support for specifying the maximum commit count --- local/handler/PushHandler.py | 35 +++++++++++++++++++++++++++-------- local/theme/DefaultTheme.py | 7 +++++++ 2 files changed, 34 insertions(+), 8 deletions(-) (limited to 'local') diff --git a/local/handler/PushHandler.py b/local/handler/PushHandler.py index 903b1b6..fc33d4f 100644 --- a/local/handler/PushHandler.py +++ b/local/handler/PushHandler.py @@ -90,7 +90,7 @@ def handle(data, theme): url = urls ) - for commit in data['commits']: + def __commit(commit): if 'username' in commit['author']: author = commit['author']['username'] else: @@ -99,15 +99,34 @@ def handle(data, theme): commitBranch = branch if not commit['distinct'] and not configValue('showMergedCommits'): - continue + return False if isMerge and not commit['distinct']: - commitBranch = "%s -> %s" % ( baseBranch, branch ) + commitBranch = "%s -> %s" % (baseBranch, branch) theme.commit( - branch = commitBranch, - author = author, - id = commit['id'], - message = commit['message'], - url = getShortURL(commit['url']) + branch=commitBranch, + author=author, + id=commit['id'], + message=commit['message'], + url=getShortURL(commit['url']) ) + + return True + + i = 0 + for commit in data['commits']: + max = configValue('maxCommitCount') + print "len of data commits is " + str(len(data['commits'])) + " while max+1= " + str(max+1) + if max != 0 and len(data['commits']) != max + 1 and i >= max: + theme.more( + branch = branch, + number = len(data['commits']) - i, + type = "commits" + ) + break + + if __commit(commit): + i += 1 + + diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py index 4215f51..d9ee11a 100644 --- a/local/theme/DefaultTheme.py +++ b/local/theme/DefaultTheme.py @@ -197,6 +197,13 @@ class DefaultTheme(Theme): ircutils.mircColor(message, "light blue") )) + def more(self, branch, number, type): + self.msgs.append("%s: ...and %d more %s" % ( + self.repo(branch), + number, + type + )) + def unknown(self, eventType, action, actor, url): if action is not None: if eventType is None: -- cgit v1.2.3