From cc203f17566ab003b176f8112b2a53a631f6a48a Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 16 Apr 2019 10:20:11 +0100 Subject: Show a push event even when there's no commits in it --- modules/github/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/github') diff --git a/modules/github/__init__.py b/modules/github/__init__.py index 1a011f17..7b72700a 100644 --- a/modules/github/__init__.py +++ b/modules/github/__init__.py @@ -466,17 +466,20 @@ class Module(ModuleManager.BaseModule): outputs = [] branch = data["ref"].split("/", 2)[2] branch = utils.irc.color(branch, COLOR_BRANCH) + author = utils.irc.bold(data["pusher"]["name"]) forced = "" if data["forced"]: forced = "%s " % utils.irc.color("force", utils.consts.RED) - if len(data["commits"]) <= 3: + if len(data["commits"]) == 0: + outputs.append( + "%s %spushed to %s" % (author, forced, branch)) + elif len(data["commits"]) <= 3: for commit in data["commits"]: hash = commit["id"] hash_colored = utils.irc.color(self._short_hash(hash), COLOR_ID) message = commit["message"].split("\n")[0].strip() - author = utils.irc.bold(data["pusher"]["name"]) url = self._short_url(COMMIT_URL % (full_name, hash)) outputs.append( @@ -485,12 +488,11 @@ class Module(ModuleManager.BaseModule): else: first_id = data["before"] last_id = data["commits"][-1]["id"] - pusher = utils.irc.bold(data["pusher"]["name"]) url = self._short_url( COMMIT_RANGE_URL % (full_name, first_id, last_id)) outputs.append("%s %spushed %d commits to %s - %s" - % (pusher, forced, len(data["commits"]), branch, url)) + % (author, forced, len(data["commits"]), branch, url)) return outputs -- cgit v1.3.1-10-gc9f91