Add option to filter out merge commits in push events
Problem to solve
Currently, push events via webhooks integration support only branch filtering:
Push events can be filtered by branch using a branch name or wildcard pattern to limit which push events are sent to your webhook endpoint. By default the field is blank causing all push events to be sent to your webhook endpoint.
This will trigger an event and include all (max 20) commits in the message including merge commits when not using fast-forward merge in project settings.
This can lead to more verbose git history and slack messages. For example, see commit https://gitlab.com/gitlab-org/design.gitlab.com/commit/5b91556202325bdd48d491da444f58747779e560 v. https://gitlab.com/gitlab-org/design.gitlab.com/commit/c0f2c65b0836dfc157b021b441e4b987b9ac766c along with their corresponding merge requests https://gitlab.com/gitlab-org/design.gitlab.com/merge_requests/1293 v. https://gitlab.com/gitlab-org/design.gitlab.com/merge_requests/1346. See also relevant slack discussion (internal).
Also, at the moment you cannot navigate back to the merge request from the commit when you squash commits and merge regardless of the fast-forward merge setting mentioned above (see https://gitlab.com/gitlab-org/gitlab-ce/issues/47688).
Intended users
This affects people that are using the webhooks integration for receiving messages about push events in slack for example. Let's add here gitlab-ce10004707 and gitlab-ce9335216 who are also involved in the use case below.
Further details
Here's a use case:
Currently, gitlab-design
(see commits) and design.gitlab.com
(see commits) repositories do use fast-forward merge but gitlab-svgs
(see commits) is not. Having all these three repositories adding push event messages can make a slack channel feel cluttered.
Proposal
One option would be to switch all repositories to using fast-forward merge. However, sometimes merge commits could be needed for conformity or history, and more (see gitlab-svgs#48 (comment 181156865), gitlab-svgs#48 (comment 181160824), and gitlab-svgs#48 (comment 181321700)).
So, providing an option to skip merge commits in the message, during webhook setup, would be helpful.
You can already filter merge commits using the following git
command:
git log --no-merges