Commit a1be5809 authored by Matija Čupić's avatar Matija Čupić

Implement Command#ambiguous_ref?

parent 9f6d228d
......@@ -57,6 +57,12 @@ module Gitlab
project.protected_for?(origin_ref)
end
end
def ambiguous_ref?
strong_memoize(:ambiguous_ref) do
project.repository.ambiguous_ref?(origin_ref)
end
end
end
end
end
......
......@@ -17,7 +17,7 @@ module Gitlab
return error('Commit not found')
end
if @command.project.repository.ambiguous_ref?(@command.origin_ref)
if @command.ambiguous_ref?
return error('Ref is ambiguous')
end
end
......
......@@ -182,4 +182,24 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
it { is_expected.to eq(false) }
end
end
describe '#ambiguous_ref' do
let(:project) { create(:project, :repository) }
let(:command) { described_class.new(project: project, origin_ref: 'ref') }
subject { command.ambiguous_ref? }
context 'when ref is not ambiguous' 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 { is_expected. to eq(true) }
end
end
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