diff --git a/app/models/repository.rb b/app/models/repository.rb index 10635eb0cf47489b3b2888e624bc92db99b0db3d..35dd120856d1f54b31152058332ccd533023c73a 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -182,16 +182,6 @@ class Repository tags.find { |tag| tag.name == name } end - def find_ref(ref) - if Gitlab::Git.tag_ref?(ref) - find_tag(Gitlab::Git.ref_name(ref)) - elsif Gitlab::Git.branch_ref?(ref) - find_branch(Gitlab::Git.ref_name(ref)) - else - nil - end - end - def add_branch(user, branch_name, ref) branch = raw_repository.add_branch(branch_name, user: user, target: ref) diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 6f9fdcf4482beb0ba4ce4fbde1bda813429fd4ae..f09b4b670619675820064853eca5879da172126f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1699,42 +1699,6 @@ describe Repository do end end - describe '#find_ref' do - subject { repository.find_ref(ref) } - - context 'when ref is a tag' do - let(:ref) { 'refs/tags/v1.0.0' } - - it 'returns a tag' do - is_expected.to be_a(Gitlab::Git::Tag) - end - - it 'returns the correct tag' do - expect(subject.name).to eq('v1.0.0') - end - end - - context 'when ref is a branch' do - let(:ref) { 'refs/heads/master' } - - it 'returns a branch' do - is_expected.to be_a(Gitlab::Git::Branch) - end - - it 'returns the correct branch' do - expect(subject.name).to eq('master') - end - end - - context 'when ref is invalid' do - let(:ref) { 'refs/notvalid/ref' } - - it 'returns nil' do - is_expected.to eq(nil) - end - end - end - describe '#avatar' do it 'returns nil if repo does not exist' do allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)