[go: up one dir, main page]

Skip to content

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