Show issue/pr number (github.py)

This commit is contained in:
jesopo 2018-12-29 19:05:14 +00:00
parent d91e15abfd
commit 5f994e599d

View file

@ -174,6 +174,7 @@ class Module(ModuleManager.BaseModule):
return ["[commit/%s] %s commented" % (commit, commenter, action)] return ["[commit/%s] %s commented" % (commit, commenter, action)]
def pull_request(self, event, full_name, data): def pull_request(self, event, full_name, data):
number = data["pull_request"]["number"]
action = data["action"] action = data["action"]
action_desc = action action_desc = action
branch = data["pull_request"]["base"]["ref"] branch = data["pull_request"]["base"]["ref"]
@ -199,28 +200,32 @@ class Module(ModuleManager.BaseModule):
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" % (author, action_desc, pr_title, url)] return ["[pr #%d] %s %s: %s - %s" % (
number, author, action_desc, pr_title, url)]
def pull_request_review(self, event, full_name, data): def pull_request_review(self, event, full_name, data):
if data["review"]["state"] == "commented": if data["review"]["state"] == "commented":
return [] return []
number = data["pull_request"]["number"]
action = data["action"] action = data["action"]
pr_title = data["pull_request"]["title"] pr_title = data["pull_request"]["title"]
reviewer = utils.irc.bold(data["sender"]["login"]) reviewer = utils.irc.bold(data["sender"]["login"])
url = self._short_url(data["review"]["html_url"]) url = self._short_url(data["review"]["html_url"])
return ["[pr] %s %s a review on: %s - %s" % (reviewer, action, pr_title, return ["[pr #%d] %s %s a review on: %s - %s" % (
url)] number, reviewer, action, pr_title, url)]
def pull_request_review_comment(self, event, full_name, data): def pull_request_review_comment(self, event, full_name, data):
number = data["pull_request"]["number"]
action = data["action"] action = data["action"]
pr_title = data["pull_request"]["title"] pr_title = data["pull_request"]["title"]
sender = data["sender"]["login"] sender = data["sender"]["login"]
url = self._short_url(data["comment"]["html_url"]) url = self._short_url(data["comment"]["html_url"])
return ["[pr] %s %s on a review: %s - %s" % return ["[pr #%d] %s %s on a review: %s - %s" %
(sender, COMMENT_ACTIONS[action], pr_title, url)] (number, sender, COMMENT_ACTIONS[action], pr_title, url)]
def issues(self, event, full_name, data): def issues(self, event, full_name, data):
number = data["issue"]["number"]
action = data["action"] action = data["action"]
action_desc = action action_desc = action
if action == "labeled": if action == "labeled":
@ -231,16 +236,17 @@ class Module(ModuleManager.BaseModule):
issue_title = data["issue"]["title"] issue_title = data["issue"]["title"]
author = utils.irc.bold(data["sender"]["login"]) author = utils.irc.bold(data["sender"]["login"])
url = self._short_url(data["issue"]["html_url"]) url = self._short_url(data["issue"]["html_url"])
return ["[issue] %s %s: %s - %s" % return ["[issue #%d] %s %s: %s - %s" %
(author, action_desc, issue_title, url)] (number, author, action_desc, issue_title, url)]
def issue_comment(self, event, full_name, data): def issue_comment(self, event, full_name, data):
number = data["issue"]["number"]
action = data["action"] action = data["action"]
issue_title = data["issue"]["title"] issue_title = data["issue"]["title"]
type = "pr" if "pull_request" in data["issue"] else "issue" type = "pr" if "pull_request" in data["issue"] else "issue"
commenter = utils.irc.bold(data["comment"]["user"]["login"]) commenter = utils.irc.bold(data["comment"]["user"]["login"])
url = self._short_url(data["comment"]["html_url"]) url = self._short_url(data["comment"]["html_url"])
return ["[%s] %s %s on: %s - %s" % return ["[%s #%d] %s %s on: %s - %s" %
(type, commenter, COMMENT_ACTIONS[action], issue_title, (number, type, commenter, COMMENT_ACTIONS[action], issue_title,
url)] url)]
def create(self, event, full_name, data): def create(self, event, full_name, data):