Commit 460c0b63 authored by Patrick Steinhardt's avatar Patrick Steinhardt Committed by Matthias Käppler

Convert blob service to use ListLFSPointers

Gitaly has recently deprecated both the GetLFSPointers and
GetAllLFSPointers RPCs in favor of ListLFSPointers, which is a more
flexible variant which simply takes a list of revisions (including
the pseudo-revs `--not` and `--all`) and then returns all LFS pointers
reachable via these revisions.

Convert the `BlobService::get_new_lfs_pointers` and
`BlobService::get_all_lfs_pointers` RPCs to use the new RPC.
parent 31871f08
...@@ -98,11 +98,12 @@ module Gitlab ...@@ -98,11 +98,12 @@ module Gitlab
end end
def get_all_lfs_pointers def get_all_lfs_pointers
request = Gitaly::GetAllLFSPointersRequest.new( request = Gitaly::ListLFSPointersRequest.new(
repository: @gitaly_repo repository: @gitaly_repo,
revisions: [encode_binary("--all")]
) )
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_all_lfs_pointers, request, timeout: GitalyClient.medium_timeout) response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :list_lfs_pointers, request, timeout: GitalyClient.medium_timeout)
map_lfs_pointers(response) map_lfs_pointers(response)
end end
...@@ -125,19 +126,20 @@ module Gitlab ...@@ -125,19 +126,20 @@ module Gitlab
[request, :list_all_lfs_pointers] [request, :list_all_lfs_pointers]
else else
request = Gitaly::GetNewLFSPointersRequest.new( revisions = [revision]
repository: @gitaly_repo, revisions += if not_in.nil? || not_in == :all
revision: encode_binary(revision), ["--not", "--all"]
limit: limit || 0
)
if not_in.nil? || not_in == :all
request.not_in_all = true
else else
request.not_in_refs += not_in not_in.prepend "--not"
end end
[request, :get_new_lfs_pointers] request = Gitaly::ListLFSPointersRequest.new(
repository: @gitaly_repo,
limit: limit || 0,
revisions: revisions.map { |rev| encode_binary(rev) }
)
[request, :list_lfs_pointers]
end end
end end
......
...@@ -14,14 +14,14 @@ RSpec.describe Gitlab::GitalyClient::BlobService do ...@@ -14,14 +14,14 @@ RSpec.describe Gitlab::GitalyClient::BlobService do
let(:limit) { 5 } let(:limit) { 5 }
let(:not_in) { %w[branch-a branch-b] } let(:not_in) { %w[branch-a branch-b] }
let(:expected_params) do let(:expected_params) do
{ revision: revision, limit: limit, not_in_refs: not_in, not_in_all: false } { revisions: ["master", "--not", "branch-a", "branch-b"], limit: limit }
end end
subject { client.get_new_lfs_pointers(revision, limit, not_in) } subject { client.get_new_lfs_pointers(revision, limit, not_in) }
it 'sends a get_new_lfs_pointers message' do it 'sends a get_new_lfs_pointers message' do
expect_any_instance_of(Gitaly::BlobService::Stub) expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_new_lfs_pointers) .to receive(:list_lfs_pointers)
.with(gitaly_request_with_params(expected_params), kind_of(Hash)) .with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return([]) .and_return([])
...@@ -31,12 +31,12 @@ RSpec.describe Gitlab::GitalyClient::BlobService do ...@@ -31,12 +31,12 @@ RSpec.describe Gitlab::GitalyClient::BlobService do
context 'with not_in = :all' do context 'with not_in = :all' do
let(:not_in) { :all } let(:not_in) { :all }
let(:expected_params) do let(:expected_params) do
{ revision: revision, limit: limit, not_in_refs: [], not_in_all: true } { revisions: ["master", "--not", "--all"], limit: limit }
end end
it 'sends the correct message' do it 'sends the correct message' do
expect_any_instance_of(Gitaly::BlobService::Stub) expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_new_lfs_pointers) .to receive(:list_lfs_pointers)
.with(gitaly_request_with_params(expected_params), kind_of(Hash)) .with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return([]) .and_return([])
...@@ -73,12 +73,16 @@ RSpec.describe Gitlab::GitalyClient::BlobService do ...@@ -73,12 +73,16 @@ RSpec.describe Gitlab::GitalyClient::BlobService do
end end
describe '#get_all_lfs_pointers' do describe '#get_all_lfs_pointers' do
let(:expected_params) do
{ revisions: ["--all"], limit: 0 }
end
subject { client.get_all_lfs_pointers } subject { client.get_all_lfs_pointers }
it 'sends a get_all_lfs_pointers message' do it 'sends a get_all_lfs_pointers message' do
expect_any_instance_of(Gitaly::BlobService::Stub) expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_all_lfs_pointers) .to receive(:list_lfs_pointers)
.with(gitaly_request_with_params({}), kind_of(Hash)) .with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return([]) .and_return([])
subject subject
......
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