From 2c8a94dc4ce022c2a8c5be7192b500f2e91928a0 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 19 Nov 2019 17:14:31 +0000 Subject: [PATCH] show who opened a pull request for pull_request events when appropriate --- modules/git_webhooks/github.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/modules/git_webhooks/github.py b/modules/git_webhooks/github.py index 8cedae2a..50c31f10 100644 --- a/modules/git_webhooks/github.py +++ b/modules/git_webhooks/github.py @@ -264,13 +264,17 @@ class GitHub(object): def pull_request(self, full_name, data): raw_number = data["pull_request"]["number"] - number = utils.irc.color("#%s" % data["pull_request"]["number"], - colors.COLOR_ID) - action = data["action"] - action_desc = "%s %s" % (action, number) branch = data["pull_request"]["base"]["ref"] colored_branch = utils.irc.color(branch, colors.COLOR_BRANCH) - author = utils.irc.bold(data["sender"]["login"]) + sender = utils.irc.bold(data["sender"]["login"]) + + author = utils.irc.bold(data["pull_request"]["user"]["login"]) + number = utils.irc.color("#%s" % data["pull_request"]["number"], + colors.COLOR_ID) + identifier = "%s by %s" % (number, author) + + action = data["action"] + action_desc = "%s %s" % (action, identifier) if action == "opened": action_desc = "requested %s merge into %s" % (number, @@ -278,11 +282,12 @@ class GitHub(object): elif action == "closed": if data["pull_request"]["merged"]: action_desc = "%s %s into %s" % ( - utils.irc.color("merged", colors.COLOR_POSITIVE), number, - colored_branch) + utils.irc.color("merged", colors.COLOR_POSITIVE), + identifier, colored_branch) else: action_desc = "%s %s" % ( - utils.irc.color("closed", colors.COLOR_NEGATIVE), number) + utils.irc.color("closed", colors.COLOR_NEGATIVE), + identifier) elif action == "ready_for_review": action_desc = "marked %s ready for review" % number elif action == "synchronize": @@ -310,12 +315,13 @@ class GitHub(object): outputs[i] = "[PR] %s" % output return outputs elif action == "labeled": - action_desc = "labled %s as '%s'" % (number, data["label"]["name"]) + action_desc = "labled %s as '%s'" % ( + identifier, data["label"]["name"]) pr_title = data["pull_request"]["title"] url = self._short_url(data["pull_request"]["html_url"]) return ["[PR] %s %s: %s - %s" % ( - author, action_desc, pr_title, url)] + sender, action_desc, pr_title, url)] def pull_request_review(self, full_name, data): if not data["action"] == "submitted":