Push rule to restrict branch name allows you to push a new branch (with a commit) but blocks a merge to master
ZD ticket: https://gitlab.zendesk.com/agent/tickets/83398
Summary
Push rule to restrict branch name allows you to push a new branch (with a commit) but blocks a merge to master.
Steps to reproduce
- Create a new push rule for to restrict branch name. Use Ruby regex
(nfr|bug|feature|hotfix|renovate)\/(ACFD|ACTST)\-\d+\-(\w+\-*)*
- From the commandline:
$ git checkout -b nfr/ACFD-107-test
# Edit a file, add your commit and commit message
$ git push origin nfr/ACFD-107-test
# Push succeeds and you get a URL to create a merge request
Counting objects: 3, done.
Writing objects: 100% (3/3), 266 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for nfr/ACFD-107-test, visit:
remote: http://<domain>/root/test-push-rule/merge_requests/new?merge_request%5Bsource_branch%5D=nfr%2FACFD-107-test
remote:
To http://gitlab-ee-version/root/test-push-rule.git
* [new branch] nfr/ACFD-107-test -> nfr/ACFD-107-test
- Click the URL to create a merge request
- Click on Merge
- Merge fails with:
GitLab: Branch name does not follow the pattern '(nfr|bug|feature|hotfix|renovate)\/(ACFD|ACTST)\-\d+\-(\w+\-*)*' .
Same error in the production.log
==> /var/log/gitlab/gitlab-rails/production.log <==
MergeService ERROR: root/test-push-rule!1 - GitLab: Branch name does not follow the pattern '(nfr|bug|feature|hotfix|renovate)\/(ACFD|ACTST)\-\d+\-(\w+\-*)*'
I validated the regex at http://rubular.com/:
I was also able to reproduce this using a simpler regex ((feature|hotfix)\/*
) and branch name feature/signup
.
Example Project
https://gitlab.com/dummy-projects/branch-name-push-rule/merge_requests/1