Add branch name to BranchCheck error message
What does this MR do and why?
Add branch name to the BranchCheck error message.
- Closes Improve branch name error message (#237884)
- Helps determine what the problem is for Cannot merge into non-default branch when using... (#214588)
Screenshots or screen recordings
Context | Image |
---|---|
Prior to this MR | |
After this MR is applied | |
In the Web IDE |
and if you try pushing commits to a branch with a name that is not on the allowlist:
$ git push
warning: redirecting to https://example.gitlab.com/root/zd346822.git/
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 335 bytes | 335.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: GitLab: Branch name 'develop' does not follow the pattern 'feature\/.*'
To https://example.gitlab.com/root/zd346822
! [remote rejected] develop -> develop (pre-receive hook declined)
How to set up and validate locally
Test 1
- Create a new project. Let's assume the default branch is
main
. - Create a
develop
branch. - Create a
feature/1
branch. - Add a branch name push rule of
feature\/.*
to the project. - Add a file to the
feature/1
branch so we have something to merge. - Create a merge request on the
feature/1
branch, with a target branch on thedevelop
branch. - Attempt to merge the MR and observe the error message.
Test 2
- Push a commit to the
develop
branch in the git CLI.
Test 3
- Edit/Add a new file in the Web IDE
- Make a commit, with the target branch as 'test'.
- Click
Make commit
. It should fail with the new error message.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Kenneth Chu