Commit 09d8c77a authored by Matija Čupić's avatar Matija Čupić

Prevent checking protected_ref? for ambiguous refs

parent dedaec13
...@@ -53,6 +53,8 @@ module Gitlab ...@@ -53,6 +53,8 @@ module Gitlab
end end
def protected_ref? def protected_ref?
return if ambiguous_ref?
strong_memoize(:protected_ref) do strong_memoize(:protected_ref) do
project.protected_for?(origin_ref) project.protected_for?(origin_ref)
end end
......
...@@ -181,6 +181,17 @@ describe Gitlab::Ci::Pipeline::Chain::Command do ...@@ -181,6 +181,17 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
context 'when ref is ambiguous' do
before do
project.repository.add_tag(project.creator, 'ref', 'master')
project.repository.add_branch(project.creator, 'ref', 'master')
end
it 'does not raise an error' do
expect { subject }.not_to raise_error
end
end
end end
describe '#ambiguous_ref' do describe '#ambiguous_ref' do
......
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