Commit 024e89e5 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'pks-lfs-use-list-lfs-pointers' into 'master'

Convert blob service to use ListLFSPointers

See merge request gitlab-org/gitlab!59377
parents 3c3cfac1 460c0b63
...@@ -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]
revisions += if not_in.nil? || not_in == :all
["--not", "--all"]
else
not_in.prepend "--not"
end
request = Gitaly::ListLFSPointersRequest.new(
repository: @gitaly_repo, 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, :list_lfs_pointers]
request.not_in_all = true
else
request.not_in_refs += not_in
end
[request, :get_new_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