[go: up one dir, main page]

Skip to content

Show the matching protected branch pattern causing branch creation to fail

Problem to solve

When trying to create a protected branch without the required permissions, GitLab helpfully outputs a message explaining that the branch is protected. However, protected branches can be reserved in advance with globs, and it may not be obvious to the user which glob they matched.

Intended users

Anyone creating branches

User experience goal

The user should be able to tell at a glance which part of the branch name was illegal

Proposal

Expand the error message with the pattern that matched the branch name. The message currently says

You are not allowed to create protected branches on this project.

but I would like it to say something like:

You are not allowed to create protected branches on this project (branch name "$branch" matched protected branch pattern "$pattern")

Further details

As an example affecting our own engineers, gitlab-org/gitlab seems to have a glob of the form *auto-deploy*, preventing any branch with auto-deploy as a substring from being created.

This is understandable, as it has to do with how GitLab.com is deployed, but GitLab also has a feature called Auto Deploy, and an external CI component called auto-deploy-image. Thus, engineers are likely to end up using auto-deploy as a substring in their branch name when working on a feature, and have a hard time figuring out why that branch name is protected. I have personally run into this, and so has @Alexand. The error message looks like this:

$ git push -u origin jcunha/set-auto-deploy-image-to-0-17-0
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 8 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.89 KiB | 646.00 KiB/s, done.
Total 9 (delta 7), reused 0 (delta 0), pack-reused 0
remote: GitLab: You are not allowed to create protected branches on this project.
To gitlab.com:gitlab-org/gitlab.git
 ! [remote rejected]         jcunha/set-auto-deploy-image-to-0-17-0 -> jcunha/set-auto-deploy-image-to-0-17-0 (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:gitlab-org/gitlab.git'

the relevant line here is

remote: GitLab: You are not allowed to create protected branches on this project.

I would have liked to see

remote: GitLab: You are not allowed to create protected branches on this project 
  (branch name "jcunha/set-auto-deploy-image-to-0-17-0" matched protected branch pattern "*auto-deploy*")

Permissions and Security

Documentation

Availability & Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Links / references

Edited by Hordur Freyr Yngvason