Read about our upcoming Code of Conduct on this issue

Commit f55f24c4 authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch 'valid-branch-name-dash-bug' into 'master'

Prevent branches or tags from starting with invalid characters (e.g. -, .)

Closes #38817

See merge request gitlab-org/gitlab-ce!14710
---
title: Prevent branches or tags from starting with invalid characters (e.g. -, .)
merge_request:
author:
type: fixed
......@@ -11,7 +11,7 @@ def validate(ref_name)
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 @@
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 @@
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment