Commit 29799405 authored by James Fargher's avatar James Fargher

Merge branch 'pks-remove-ref-name-for-sha' into 'master'

repository: Remove `#ref_name_for_sha`

See merge request gitlab-org/gitlab!68479
parents 654df34d ec8ca3cd
......@@ -491,13 +491,6 @@ module Gitlab
[]
end
# Returns a RefName for a given SHA
def ref_name_for_sha(ref_path, sha)
raise ArgumentError, "sha can't be empty" unless sha.present?
gitaly_ref_client.find_ref_name(sha, ref_path)
end
# Get refs hash which key is the commit id
# and value is a Gitlab::Git::Tag or Gitlab::Git::Branch
# Note that both inherit from Gitlab::Git::Ref
......
......@@ -52,16 +52,6 @@ module Gitlab
consume_refs_response(response) { |name| Gitlab::Git.tag_name(name) }
end
def find_ref_name(commit_id, ref_prefix)
request = Gitaly::FindRefNameRequest.new(
repository: @gitaly_repo,
commit_id: commit_id,
prefix: ref_prefix
)
response = GitalyClient.call(@storage, :ref_service, :find_ref_name, request, timeout: GitalyClient.medium_timeout)
encode!(response.name.dup)
end
def list_new_blobs(newrev, limit = 0, dynamic_timeout: nil)
request = Gitaly::ListNewBlobsRequest.new(
repository: @gitaly_repo,
......
......@@ -1132,28 +1132,6 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end
end
describe '#ref_name_for_sha' do
let(:ref_path) { 'refs/heads' }
let(:sha) { repository.find_branch('master').dereferenced_target.id }
let(:ref_name) { 'refs/heads/master' }
it 'returns the ref name for the given sha' do
expect(repository.ref_name_for_sha(ref_path, sha)).to eq(ref_name)
end
it "returns an empty name if the ref doesn't exist" do
expect(repository.ref_name_for_sha(ref_path, "000000")).to eq("")
end
it "raise an exception if the ref is empty" do
expect { repository.ref_name_for_sha(ref_path, "") }.to raise_error(ArgumentError)
end
it "raise an exception if the ref is nil" do
expect { repository.ref_name_for_sha(ref_path, nil) }.to raise_error(ArgumentError)
end
end
describe '#branches' do
subject { repository.branches }
......
......@@ -189,13 +189,6 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
describe '#find_ref_name', :seed_helper do
subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') }
it { is_expected.to be_utf8 }
it { is_expected.to eq('refs/heads/master') }
end
describe '#ref_exists?', :seed_helper do
it 'finds the master branch ref' do
expect(client.ref_exists?('refs/heads/master')).to eq(true)
......
......@@ -142,15 +142,6 @@ RSpec.describe Repository do
end
end
describe '#ref_name_for_sha' do
it 'returns the ref' do
allow(repository.raw_repository).to receive(:ref_name_for_sha)
.and_return('refs/environments/production/77')
expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77'
end
end
describe '#ref_exists?' do
context 'when ref exists' do
it 'returns true' do
......
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