Remove Repository#find_ref

上级 96a0a8cf
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册