debian-mirror-gitlab/lib/gitlab/git/object_pool.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
module Git
class ObjectPool
# GL_REPOSITORY has to be passed for Gitlab::Git::Repositories, but not
# used for ObjectPools.
GL_REPOSITORY = ""
delegate :exists?, :size, to: :repository
2019-07-07 11:18:12 +05:30
delegate :delete, to: :object_pool_service
2019-02-15 15:39:39 +05:30
2019-03-02 22:35:43 +05:30
attr_reader :storage, :relative_path, :source_repository, :gl_project_path
2019-02-15 15:39:39 +05:30
2019-03-02 22:35:43 +05:30
def initialize(storage, relative_path, source_repository, gl_project_path)
2019-02-15 15:39:39 +05:30
@storage = storage
@relative_path = relative_path
@source_repository = source_repository
2019-03-02 22:35:43 +05:30
@gl_project_path = gl_project_path
2019-02-15 15:39:39 +05:30
end
def create
object_pool_service.create(source_repository)
end
def link(to_link_repo)
object_pool_service.link_repository(to_link_repo)
end
def gitaly_object_pool
Gitaly::ObjectPool.new(repository: to_gitaly_repository)
end
def to_gitaly_repository
2019-03-02 22:35:43 +05:30
Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY, gl_project_path)
2019-02-15 15:39:39 +05:30
end
# Allows for reusing other RPCs by 'tricking' Gitaly to think its a repository
def repository
2019-03-02 22:35:43 +05:30
@repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY, gl_project_path)
2019-02-15 15:39:39 +05:30
end
2019-07-31 22:56:46 +05:30
def fetch
object_pool_service.fetch(source_repository)
end
2019-02-15 15:39:39 +05:30
private
def object_pool_service
@object_pool_service ||= Gitlab::GitalyClient::ObjectPoolService.new(self)
end
def relative_path_to(pool_member_path)
pool_path = Pathname.new("#{relative_path}#{File::SEPARATOR}")
Pathname.new(pool_member_path).relative_path_from(pool_path).to_s
end
end
end
end