From 1d777f88b3d9131f2edce63ef772f9092ed6ec73 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 1 Nov 2019 13:30:31 +0000 Subject: support "event category" for github so we can e.g. show only approvals --- modules/git_webhooks/github.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'modules/git_webhooks/github.py') diff --git a/modules/git_webhooks/github.py b/modules/git_webhooks/github.py index 1ff1e57d..fc25f0f8 100644 --- a/modules/git_webhooks/github.py +++ b/modules/git_webhooks/github.py @@ -111,10 +111,23 @@ class GitHub(object): def event(self, data, headers): event = headers["X-GitHub-Event"] + action = None event_action = None if "action" in data: - event_action = "%s/%s" % (event, data["action"]) - return [event]+([event_action] if event_action else []) + action = data["action"] + + category = None + category_action = None + if "review" in data and "state" in data["review"]: + category = "%s+%s" % (event, data["review"]["state"]) + + if action: + if category: + category_action = "%s/%s" % (category, action) + event_action = "%s/%s" % (event, action) + + return [event]+list(filter(None, + [event_action, category, category_action])) def event_categories(self, event): return EVENT_CATEGORIES.get(event, [event]) -- cgit v1.3.1-10-gc9f91