diff options
author | Matija Čupić <matteeyah@gmail.com> | 2019-01-16 20:51:41 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2019-01-16 21:38:17 +0100 |
commit | 09d8c77ab2338593a303d73360dc9e5db706394b (patch) | |
tree | abd28b5dfc33168c45703256fe7d19647d268e0e | |
parent | dedaec13a57abdbeaded37c1ae9526a4f3d82e8b (diff) | |
download | gitlab-ce-09d8c77ab2338593a303d73360dc9e5db706394b.tar.gz |
Prevent checking protected_ref? for ambiguous refs
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/command.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/command_spec.rb | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/command.rb b/lib/gitlab/ci/pipeline/chain/command.rb index e62d547d862..e0172e56f56 100644 --- a/lib/gitlab/ci/pipeline/chain/command.rb +++ b/lib/gitlab/ci/pipeline/chain/command.rb @@ -53,6 +53,8 @@ module Gitlab end def protected_ref? + return if ambiguous_ref? + strong_memoize(:protected_ref) do project.protected_for?(origin_ref) end diff --git a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb index 6aa802ce6fd..a00d4339828 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb @@ -181,6 +181,17 @@ describe Gitlab::Ci::Pipeline::Chain::Command do it { is_expected.to eq(false) } 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 describe '#ambiguous_ref' do |