Skip to content

Add get_archive to Gitaly repository client

Add Gitlab::GitalyClient::RepositoryService#get_archive (and maybe Gitlab::Git::Repository#get_archive):

def get_archive(commit, prefix: nil, format: Gitaly::GetArchiveRequest::Format::ZIP, path: nil, exclude: nil, elide_path: false, include_lfs_blobs: false)
  request = Gitaly::GetArchiveRequest.new(
    repository: @gitaly_repo,
    commit_id: commit,
    prefix: prefix,
    format: format,
    path: path,
    exclude: exclude,
    elide_path: elide_path,
    include_lfs_blobs: include_lfs_blobs,
  )
  response = GitalyClient.call(@storage, :repository_service, :get_archive, request, timeout: GitalyClient.long_timeout)

  response.each { |message| yield(message.data) }
end

With this feature, Packages::Go::ModuleVersion#archive could be implemented as a Gitaly call, instead of the current implementation, which queries Gitaly for blobs and constructs the archive in Ruby.

Given the number of MRs I have open, I will not be creating an MR for this at the moment.

Edited by Ethan Reesor