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