Raise an error on ambiguous refs

This commit is contained in:
Matija Čupić 2018-11-28 15:43:58 +01:00
parent dfe7f57eef
commit 08942de9b6
No known key found for this signature in database
GPG Key ID: 4BAF84FFACD2E5DE
3 changed files with 5 additions and 3 deletions

View File

@ -1737,7 +1737,8 @@ class Project < ActiveRecord::Base
end
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)
resolved_ref = ref

View File

@ -26,6 +26,7 @@ class Repository
delegate :bundle_to_disk, to: :raw_repository
CreateTreeError = Class.new(StandardError)
AmbiguousRefError = Class.new(StandardError)
# Methods that cache data from the Git repository.
#

View File

@ -2583,8 +2583,8 @@ describe Project do
project.repository.add_tag(project.creator, ref, 'master')
end
it 'returns false' do
is_expected.to be_falsey
it 'raises an error' do
expect { subject }.to raise_error(Repository::AmbiguousRefError)
end
end