Prevent branches or tags from starting with invalid characters (e.g. -, .)
Closes #38817
This commit is contained in:
parent
2e76b8a960
commit
351fde1b90
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Prevent branches or tags from starting with invalid characters (e.g. -, .)
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
||||
|
|
@ -11,7 +11,7 @@ module Gitlab
|
|||
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}))
|
||||
%W(#{Gitlab.config.git.bin_path} check-ref-format --branch #{ref_name}))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ describe Gitlab::GitRefValidator do
|
|||
it { expect(described_class.validate('feature/new')).to be_truthy }
|
||||
it { expect(described_class.validate('implement_@all')).to be_truthy }
|
||||
it { expect(described_class.validate('my_new_feature')).to be_truthy }
|
||||
it { expect(described_class.validate('my-branch')).to be_truthy }
|
||||
it { expect(described_class.validate('#1')).to be_truthy }
|
||||
it { expect(described_class.validate('feature/refs/heads/foo')).to be_truthy }
|
||||
it { expect(described_class.validate('feature/~new/')).to be_falsey }
|
||||
|
|
@ -22,4 +23,8 @@ describe Gitlab::GitRefValidator do
|
|||
it { expect(described_class.validate('refs/remotes/')).to be_falsey }
|
||||
it { expect(described_class.validate('refs/heads/feature')).to be_falsey }
|
||||
it { expect(described_class.validate('refs/remotes/origin')).to be_falsey }
|
||||
it { expect(described_class.validate('-')).to be_falsey }
|
||||
it { expect(described_class.validate('-branch')).to be_falsey }
|
||||
it { expect(described_class.validate('.tag')).to be_falsey }
|
||||
it { expect(described_class.validate('my branch')).to be_falsey }
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue