diff options
| author | 2019-10-28 14:10:42 +0000 | |
|---|---|---|
| committer | 2019-10-28 14:10:42 +0000 | |
| commit | 7766c889f460a427cd1f3fe5711c32fe2a2bee56 (patch) | |
| tree | 4b7a214ce833b45c6081e19520c3e308a272e40b /modules/git_webhooks/gitlab.py | |
| parent | fix relay exception (diff) | |
| signature | ||
support event 'category' for GitLab (e.g. Note events but only for Issues)
Diffstat (limited to 'modules/git_webhooks/gitlab.py')
| -rw-r--r-- | modules/git_webhooks/gitlab.py | 20 |
1 files changed, 15 insertions, 5 deletions
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]) |
