Show a push event even when there's no commits in it

This commit is contained in:
jesopo 2019-04-16 10:20:11 +01:00
parent 34848324d5
commit cc203f1756

View file

@ -466,17 +466,20 @@ class Module(ModuleManager.BaseModule):
outputs = [] outputs = []
branch = data["ref"].split("/", 2)[2] branch = data["ref"].split("/", 2)[2]
branch = utils.irc.color(branch, COLOR_BRANCH) branch = utils.irc.color(branch, COLOR_BRANCH)
author = utils.irc.bold(data["pusher"]["name"])
forced = "" forced = ""
if data["forced"]: if data["forced"]:
forced = "%s " % utils.irc.color("force", utils.consts.RED) 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"]: for commit in data["commits"]:
hash = commit["id"] hash = commit["id"]
hash_colored = utils.irc.color(self._short_hash(hash), COLOR_ID) hash_colored = utils.irc.color(self._short_hash(hash), COLOR_ID)
message = commit["message"].split("\n")[0].strip() message = commit["message"].split("\n")[0].strip()
author = utils.irc.bold(data["pusher"]["name"])
url = self._short_url(COMMIT_URL % (full_name, hash)) url = self._short_url(COMMIT_URL % (full_name, hash))
outputs.append( outputs.append(
@ -485,12 +488,11 @@ class Module(ModuleManager.BaseModule):
else: else:
first_id = data["before"] first_id = data["before"]
last_id = data["commits"][-1]["id"] last_id = data["commits"][-1]["id"]
pusher = utils.irc.bold(data["pusher"]["name"])
url = self._short_url( url = self._short_url(
COMMIT_RANGE_URL % (full_name, first_id, last_id)) COMMIT_RANGE_URL % (full_name, first_id, last_id))
outputs.append("%s %spushed %d commits to %s - %s" 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 return outputs