Skip to content

Add branch name to BranchCheck error message

Kenneth Chu requested to merge kenneth-show-branch-name-push-rule-error into master

What does this MR do and why?

Add branch name to the BranchCheck error message.

Screenshots or screen recordings

Context Image
Prior to this MR image
After this MR is applied image
In the Web IDE image

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

  1. Create a new project. Let's assume the default branch is main.
  2. Create a develop branch.
  3. Create a feature/1 branch.
  4. Add a branch name push rule of feature\/.* to the project.
  5. Add a file to the feature/1 branch so we have something to merge.
  6. Create a merge request on the feature/1 branch, with a target branch on the develop branch.
  7. Attempt to merge the MR and observe the error message.

Test 2

  1. Push a commit to the develop branch in the git CLI.

Test 3

  1. Edit/Add a new file in the Web IDE
  2. Make a commit, with the target branch as 'test'.
  3. 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.

Edited by Kenneth Chu

Merge request reports

Loading