Move PR number into/after action for pull_request events

This commit is contained in:
jesopo 2019-03-07 08:35:29 +00:00
parent 6b59830a6e
commit b9fa74dbb5

View file

@ -495,28 +495,30 @@ class Module(ModuleManager.BaseModule):
number = utils.irc.color("#%s" % data["pull_request"]["number"], number = utils.irc.color("#%s" % data["pull_request"]["number"],
COLOR_ID) COLOR_ID)
action = data["action"] action = data["action"]
action_desc = action action_desc = "%s %s" % (action, number)
branch = data["pull_request"]["base"]["ref"] branch = data["pull_request"]["base"]["ref"]
colored_branch = utils.irc.color(branch, COLOR_BRANCH) colored_branch = utils.irc.color(branch, COLOR_BRANCH)
if action == "opened": if action == "opened":
action_desc = "requested merge into %s" % colored_branch action_desc = "requested %s merge into %s" % (number,
colored_branch)
elif action == "closed": elif action == "closed":
if data["pull_request"]["merged"]: if data["pull_request"]["merged"]:
action_desc = "%s into %s" % ( action_desc = "%s %s into %s" % (
utils.irc.color("merged", COLOR_POSITIVE), utils.irc.color("merged", COLOR_POSITIVE), number,
colored_branch) colored_branch)
else: else:
action_desc = utils.irc.color("closed without merging", action_desc = "%s %s %s" % (
COLOR_NEGATIVE) utils.irc.color("closed", COLOR_NEGATIVE), number,
utils.irc.color("without merging", COLOR_NEGATIVE))
elif action == "synchronize": elif action == "synchronize":
action_desc = "committed to" action_desc = "committed to %s" % number
pr_title = data["pull_request"]["title"] pr_title = data["pull_request"]["title"]
author = utils.irc.bold(data["sender"]["login"]) author = utils.irc.bold(data["sender"]["login"])
url = self._short_url(data["pull_request"]["html_url"]) url = self._short_url(data["pull_request"]["html_url"])
return ["[PR %s] %s %s: %s - %s" % ( return ["[PR] %s %s: %s - %s" % (
number, author, action_desc, pr_title, url)] author, action_desc, pr_title, url)]
def pull_request_review(self, full_name, data): def pull_request_review(self, full_name, data):
if data["review"]["state"] == "commented": if data["review"]["state"] == "commented":