Push rule to reject commit message also blocks a merge to master when merging with a commit message
Summary
Adding a push rule to restrict commit messages works except when merging the branch. I found this error happens when the Merge commit option is selected under the project's Merge Request Settings, and doesn't happen when Fast-forward merge is selected.
Reproduction steps
- Create a project
- Create a new branch and merge request
- Add the following push rule in the project settings:
(feat|fix|docs|style|refactor|test|chore)\([^)]+\): [a-z0-9]+.*(\s{2,}(.*|\s)+|)
- Ensure that Merge commit is the preferred merge request method under the project settings
- Make a change on the new branch by adding a file and giving it the commit message chore(*): fix something, which correctly succeeds
- Attempt to merge the merge request, which fails with the error
Commit message does not follow the pattern '(feat|fix|docs|style|refactor|test|chore)\([^)]+\): [a-z0-9]+.*(\s{2,}(.*|\s)+|)'.
This was reproduced on gitlab.com (11.0.2-ee) and a test 10.7.5-ee instance.
Maybe we can either:
- allow these merge commits in spite of the push rule or
- have a notice by the push rule stating that Fast-forward merge must be selected
Links
- Zendesk ticket: https://gitlab.zendesk.com/agent/tickets/99203
- Example merge request that fails on gitlab.com: harish_test_group/push-rules!2
- Rubular confirmation of what the regex captures: http://rubular.com/r/8B11BBJK6C
- This issue looks similar to https://gitlab.com/gitlab-org/gitlab-ee/issues/3670 except that it's for commit messages.