Commit 08942de9 authored by Matija Čupić's avatar Matija Čupić

Raise an error on ambiguous refs

parent dfe7f57e
...@@ -1737,7 +1737,8 @@ class Project < ActiveRecord::Base ...@@ -1737,7 +1737,8 @@ class Project < ActiveRecord::Base
end end
def protected_for?(ref) def protected_for?(ref)
return false if ref.nil? || repository.ambiguous_ref?(ref) return false if ref.nil?
raise Repository::AmbiguousRefError if repository.ambiguous_ref?(ref)
if Gitlab::Git.branch_ref?(ref) || Gitlab::Git.tag_ref?(ref) if Gitlab::Git.branch_ref?(ref) || Gitlab::Git.tag_ref?(ref)
resolved_ref = ref resolved_ref = ref
......
...@@ -26,6 +26,7 @@ class Repository ...@@ -26,6 +26,7 @@ class Repository
delegate :bundle_to_disk, to: :raw_repository delegate :bundle_to_disk, to: :raw_repository
CreateTreeError = Class.new(StandardError) CreateTreeError = Class.new(StandardError)
AmbiguousRefError = Class.new(StandardError)
# Methods that cache data from the Git repository. # Methods that cache data from the Git repository.
# #
......
...@@ -2583,8 +2583,8 @@ describe Project do ...@@ -2583,8 +2583,8 @@ describe Project do
project.repository.add_tag(project.creator, ref, 'master') project.repository.add_tag(project.creator, ref, 'master')
end end
it 'returns false' do it 'raises an error' do
is_expected.to be_falsey expect { subject }.to raise_error(Repository::AmbiguousRefError)
end 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