Class: Gitlab::Git::ObjectPool

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/git/object_pool.rb

Constant Summary collapse

GL_REPOSITORY =

GL_REPOSITORY has to be passed for Gitlab::Git::Repositories, but not used for ObjectPools.

""

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage, relative_path, source_repository, gl_project_path) ⇒ ObjectPool

Returns a new instance of ObjectPool.



26
27
28
29
30
31
# File 'lib/gitlab/git/object_pool.rb', line 26

def initialize(storage, relative_path, source_repository, gl_project_path)
  @storage = storage
  @relative_path = relative_path
  @source_repository = source_repository
  @gl_project_path = gl_project_path
end

Instance Attribute Details

#gl_project_pathObject (readonly)

Returns the value of attribute gl_project_path.



13
14
15
# File 'lib/gitlab/git/object_pool.rb', line 13

def gl_project_path
  @gl_project_path
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



13
14
15
# File 'lib/gitlab/git/object_pool.rb', line 13

def relative_path
  @relative_path
end

#source_repositoryObject (readonly)

Returns the value of attribute source_repository.



13
14
15
# File 'lib/gitlab/git/object_pool.rb', line 13

def source_repository
  @source_repository
end

#storageObject (readonly)

Returns the value of attribute storage.



13
14
15
# File 'lib/gitlab/git/object_pool.rb', line 13

def storage
  @storage
end

Class Method Details

.init_from_gitaly(gitaly_object_pool, source_repository) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/git/object_pool.rb', line 15

def self.init_from_gitaly(gitaly_object_pool, source_repository)
  repository = gitaly_object_pool.repository

  new(
    repository.storage_name,
    repository.relative_path,
    source_repository,
    repository.gl_project_path
  )
end

Instance Method Details

#createObject



33
34
35
# File 'lib/gitlab/git/object_pool.rb', line 33

def create
  object_pool_service.create(source_repository)
end

#fetchObject



54
55
56
# File 'lib/gitlab/git/object_pool.rb', line 54

def fetch
  object_pool_service.fetch(source_repository)
end

#gitaly_object_poolObject



41
42
43
# File 'lib/gitlab/git/object_pool.rb', line 41

def gitaly_object_pool
  Gitaly::ObjectPool.new(repository: to_gitaly_repository)
end


37
38
39
# File 'lib/gitlab/git/object_pool.rb', line 37

def link(to_link_repo)
  object_pool_service.link_repository(to_link_repo)
end

#repositoryObject

Allows for reusing other RPCs by ‘tricking’ Gitaly to think its a repository



50
51
52
# File 'lib/gitlab/git/object_pool.rb', line 50

def repository
  @repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY, gl_project_path)
end

#to_gitaly_repositoryObject



45
46
47
# File 'lib/gitlab/git/object_pool.rb', line 45

def to_gitaly_repository
  Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY, gl_project_path)
end