Can't use branche names that start with a SHA-1 or SHA-256
Summary
I cannot create branches whose name start with a SHA-1 or SHA-256. I argue that this behavior is incorrect.
Steps to reproduce
Try to create a branch named 5d2f5139e1ce5dace7854e7e6ccfcacdca48ef98-foo-bar
.
Example Project
n/a
What is the current bug behavior?
Upong git push
GitLab says
remote: GitLab: You cannot create a branch with a SHA-1 or SHA-256 branch name.
Note that using SHA-1 or SHA-256 as a suffix rather than prefix is accepted i.e. foo-bar-<sha>
works, but <sha>-foo-bar
doesn't.
What is the expected correct behavior?
This error is only thrown if the branch name actually is a SHA-1 or SHA-256 but not when it starts with a SHA-1 or SHA-256.
Relevant logs and/or screenshots
See above
Results of GitLab environment info
n/a, we're on v16.9.1-ee.
Results of GitLab application Check
n/a
Possible fixes
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/checks/branch_check.rb#L46 and https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/git/commit.rb#L23-25.
-> IMO the condition should be if %r{\A#{Gitlab::Git::Commit::RAW_FULL_SHA_PATTERN}\z}o.match?(branch_name)
, note the \z