Merge branch '26470-branch-names-with-reference-prefixes-results-in-buggy-branches' into 'master'
Strip reference prefixes on branch creation Closes #26470 See merge request !8498
This commit is contained in:
commit
d68c23a00e
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Strip reference prefixes on branch creation
|
||||
merge_request: 8498
|
||||
author: Matthieu Tardy
|
|
@ -5,6 +5,9 @@ module Gitlab
|
|||
#
|
||||
# Returns true for a valid reference name, false otherwise
|
||||
def validate(ref_name)
|
||||
return false if ref_name.start_with?('refs/heads/')
|
||||
return false if ref_name.start_with?('refs/remotes/')
|
||||
|
||||
Gitlab::Utils.system_silent(
|
||||
%W(#{Gitlab.config.git.bin_path} check-ref-format refs/#{ref_name}))
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ describe Gitlab::GitRefValidator, lib: true do
|
|||
it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/refs/heads/foo')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey }
|
||||
|
@ -17,4 +18,8 @@ describe Gitlab::GitRefValidator, lib: true do
|
|||
it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('refs/heads/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('refs/heads/feature')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('refs/remotes/origin')).to be_falsey }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue