gitlab-org--gitlab-foss/lib/gitlab/gitaly_client/util.rb

42 lines
1.5 KiB
Ruby
Raw Normal View History

module Gitlab
module GitalyClient
module Util
2017-04-06 10:54:15 -04:00
class << self
def repository(repository_storage, relative_path, gl_repository)
git_env = Gitlab::Git::HookEnv.all(gl_repository)
git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'])
2017-04-06 10:54:15 -04:00
Gitaly::Repository.new(
storage_name: repository_storage,
2017-08-09 02:36:24 -04:00
relative_path: relative_path,
gl_repository: gl_repository.to_s,
git_object_directory: git_object_directory.to_s,
git_alternate_object_directories: git_alternate_object_directories
2017-04-06 10:54:15 -04:00
)
end
def git_repository(gitaly_repository)
Gitlab::Git::Repository.new(gitaly_repository.storage_name,
gitaly_repository.relative_path,
gitaly_repository.gl_repository)
end
def gitlab_tag_from_gitaly_tag(repository, gitaly_tag)
if gitaly_tag.target_commit.present?
commit = Gitlab::Git::Commit.decorate(repository, gitaly_tag.target_commit)
end
Gitlab::Git::Tag.new(
repository,
Gitlab::EncodingHelper.encode!(gitaly_tag.name.dup),
gitaly_tag.id,
commit,
Gitlab::EncodingHelper.encode!(gitaly_tag.message.chomp)
)
end
end
end
end
end