Valid Branch Names
GitLab let's you create non valid Git branch names.
Branches cannot start with a -
... But GL let's me do it. This will break things.
Also this problem exists with tags.
The reason I believe this is happening is that we run git_ref_validator.rb
and in it we run
Gitlab::Utils.system_silent(
%W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name}))
But if you look at the git source code for branch validation you will see that strbuf_check_tag_ref
first checks the first character to see if it is a -
then it does the check_refname_format
. I think the problem is only with dashes as the first character but I am not 100% sure. I think the thing to do is just check for the dash in the code above where we check ref_name.start_with
. We could just add a check for the dash.