From 7766c889f460a427cd1f3fe5711c32fe2a2bee56 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 28 Oct 2019 14:10:42 +0000 Subject: support event 'category' for GitLab (e.g. Note events but only for Issues) --- modules/git_webhooks/gitlab.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'modules/git_webhooks/gitlab.py') diff --git a/modules/git_webhooks/gitlab.py b/modules/git_webhooks/gitlab.py index 98ddd933..998e8faf 100644 --- a/modules/git_webhooks/gitlab.py +++ b/modules/git_webhooks/gitlab.py @@ -71,13 +71,23 @@ class GitLab(object): def event(self, data, headers): event = headers["X-GitLab-Event"].rsplit(" ", 1)[0].lower() + event = event.replace(" ", "_") event_action = None - if ("object_attributes" in data and - "action" in data["object_attributes"]): - event_action = "%s/%s" % ( - event, data["object_attributes"]["action"]) - return event, event_action + + category = None + category_action = None + + if "object_attributes" in data: + if "action" in data["object_attributes"]: + event_action = "%s/%s" % ( + event, data["object_attributes"]["action"]) + if "noteable_type" in data["object_attributes"]: + category = data["object_attributes"]["noteable_type"].lower() + category = "%s+%s" % (event, category) + category_action = "%s/%s" % (category, action) + + return list(filter([event, event_action, category, category_action])) def event_categories(self, event): return EVENT_CATEGORIES.get(event, [event]) -- cgit v1.3.1-10-gc9f91