Commit f929411c authored by Stan Hu's avatar Stan Hu

Rename gl_project_name -> gl_project_path

Upgrade gitaly-proto to 1.10.0 to have this field.
parent e5990db5
...@@ -422,7 +422,7 @@ group :ed25519 do ...@@ -422,7 +422,7 @@ group :ed25519 do
end end
# Gitaly GRPC client # Gitaly GRPC client
gem 'gitaly-proto', '~> 1.5.0', require: 'gitaly' gem 'gitaly-proto', '~> 1.10.0', require: 'gitaly'
gem 'grpc', '~> 1.15.0' gem 'grpc', '~> 1.15.0'
gem 'google-protobuf', '~> 3.6' gem 'google-protobuf', '~> 3.6'
......
...@@ -277,7 +277,7 @@ GEM ...@@ -277,7 +277,7 @@ GEM
gettext_i18n_rails (>= 0.7.1) gettext_i18n_rails (>= 0.7.1)
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
gitaly-proto (1.5.0) gitaly-proto (1.10.0)
grpc (~> 1.0) grpc (~> 1.0)
github-markup (1.7.0) github-markup (1.7.0)
gitlab-default_value_for (3.1.1) gitlab-default_value_for (3.1.1)
...@@ -1016,7 +1016,7 @@ DEPENDENCIES ...@@ -1016,7 +1016,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly-proto (~> 1.5.0) gitaly-proto (~> 1.10.0)
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-default_value_for (~> 3.1.1) gitlab-default_value_for (~> 3.1.1)
gitlab-markup (~> 1.6.5) gitlab-markup (~> 1.6.5)
......
...@@ -10,13 +10,13 @@ module Gitlab ...@@ -10,13 +10,13 @@ module Gitlab
delegate :exists?, :size, to: :repository delegate :exists?, :size, to: :repository
delegate :unlink_repository, :delete, to: :object_pool_service delegate :unlink_repository, :delete, to: :object_pool_service
attr_reader :storage, :relative_path, :source_repository, :gl_project_name attr_reader :storage, :relative_path, :source_repository, :gl_project_path
def initialize(storage, relative_path, source_repository, gl_project_name) def initialize(storage, relative_path, source_repository, gl_project_path)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@source_repository = source_repository @source_repository = source_repository
@gl_project_name = gl_project_name @gl_project_path = gl_project_path
end end
def create def create
...@@ -32,12 +32,12 @@ module Gitlab ...@@ -32,12 +32,12 @@ module Gitlab
end end
def to_gitaly_repository def to_gitaly_repository
Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY, gl_project_name) Gitlab::GitalyClient::Util.repository(storage, relative_path, GL_REPOSITORY, gl_project_path)
end end
# Allows for reusing other RPCs by 'tricking' Gitaly to think its a repository # Allows for reusing other RPCs by 'tricking' Gitaly to think its a repository
def repository def repository
@repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY, gl_project_name) @repository ||= Gitlab::Git::Repository.new(storage, relative_path, GL_REPOSITORY, gl_project_path)
end end
private private
......
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
# Relative path of repo # Relative path of repo
attr_reader :relative_path attr_reader :relative_path
attr_reader :storage, :gl_repository, :relative_path, :gl_project_name attr_reader :storage, :gl_repository, :relative_path, :gl_project_path
# This remote name has to be stable for all types of repositories that # This remote name has to be stable for all types of repositories that
# can join an object pool. If it's structure ever changes, a migration # can join an object pool. If it's structure ever changes, a migration
...@@ -78,11 +78,11 @@ module Gitlab ...@@ -78,11 +78,11 @@ module Gitlab
# This initializer method is only used on the client side (gitlab-ce). # This initializer method is only used on the client side (gitlab-ce).
# Gitaly-ruby uses a different initializer. # Gitaly-ruby uses a different initializer.
def initialize(storage, relative_path, gl_repository, gl_project_name) def initialize(storage, relative_path, gl_repository, gl_project_path)
@storage = storage @storage = storage
@relative_path = relative_path @relative_path = relative_path
@gl_repository = gl_repository @gl_repository = gl_repository
@gl_project_name = gl_project_name @gl_project_path = gl_project_path
@name = @relative_path.split("/").last @name = @relative_path.split("/").last
end end
...@@ -873,7 +873,7 @@ module Gitlab ...@@ -873,7 +873,7 @@ module Gitlab
end end
def gitaly_repository def gitaly_repository
Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository, @gl_project_name) Gitlab::GitalyClient::Util.repository(@storage, @relative_path, @gl_repository, @gl_project_path)
end end
def gitaly_ref_client def gitaly_ref_client
......
...@@ -4,7 +4,7 @@ module Gitlab ...@@ -4,7 +4,7 @@ module Gitlab
module GitalyClient module GitalyClient
module Util module Util
class << self class << self
def repository(repository_storage, relative_path, gl_repository, gl_project_name) def repository(repository_storage, relative_path, gl_repository, gl_project_path)
git_env = Gitlab::Git::HookEnv.all(gl_repository) git_env = Gitlab::Git::HookEnv.all(gl_repository)
git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE']) git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'])
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
gl_repository: gl_repository.to_s, gl_repository: gl_repository.to_s,
git_object_directory: git_object_directory.to_s, git_object_directory: git_object_directory.to_s,
git_alternate_object_directories: git_alternate_object_directories, git_alternate_object_directories: git_alternate_object_directories,
gl_project_name: gl_project_name gl_project_path: gl_project_path
) )
end end
...@@ -23,7 +23,7 @@ module Gitlab ...@@ -23,7 +23,7 @@ module Gitlab
Gitlab::Git::Repository.new(gitaly_repository.storage_name, Gitlab::Git::Repository.new(gitaly_repository.storage_name,
gitaly_repository.relative_path, gitaly_repository.relative_path,
gitaly_repository.gl_repository, gitaly_repository.gl_repository,
gitaly_repository.gl_project_name) gitaly_repository.gl_project_path)
end end
end end
end end
......
...@@ -77,19 +77,19 @@ module Gitlab ...@@ -77,19 +77,19 @@ module Gitlab
# #
# storage - the shard key # storage - the shard key
# disk_path - project disk path # disk_path - project disk path
# gl_project_name - project name # gl_project_path - project name
# #
# Ex. # Ex.
# create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci") # create_repository("default", "path/to/gitlab-ci", "gitlab/gitlab-ci")
# #
def create_repository(storage, disk_path, gl_project_name) def create_repository(storage, disk_path, gl_project_path)
relative_path = disk_path.dup relative_path = disk_path.dup
relative_path << '.git' unless relative_path.end_with?('.git') relative_path << '.git' unless relative_path.end_with?('.git')
# During creation of a repository, gl_repository may not be known # During creation of a repository, gl_repository may not be known
# because that depends on a yet-to-be assigned project ID in the # because that depends on a yet-to-be assigned project ID in the
# database (e.g. project-1234), so for now it is blank. # database (e.g. project-1234), so for now it is blank.
repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_name) repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_path)
wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository } wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository }
true true
...@@ -115,13 +115,13 @@ module Gitlab ...@@ -115,13 +115,13 @@ module Gitlab
# Ex. # Ex.
# import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git") # import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git")
# #
def import_repository(storage, name, url, gl_project_name) def import_repository(storage, name, url, gl_project_path)
if url.start_with?('.', '/') if url.start_with?('.', '/')
raise Error.new("don't use disk paths with import_repository: #{url.inspect}") raise Error.new("don't use disk paths with import_repository: #{url.inspect}")
end end
relative_path = "#{name}.git" relative_path = "#{name}.git"
cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_name) cmd = GitalyGitlabProjects.new(storage, relative_path, gl_project_path)
success = cmd.import_project(url, git_timeout) success = cmd.import_project(url, git_timeout)
raise Error, cmd.output unless success raise Error, cmd.output unless success
...@@ -413,17 +413,17 @@ module Gitlab ...@@ -413,17 +413,17 @@ module Gitlab
end end
class GitalyGitlabProjects class GitalyGitlabProjects
attr_reader :shard_name, :repository_relative_path, :output, :gl_project_name attr_reader :shard_name, :repository_relative_path, :output, :gl_project_path
def initialize(shard_name, repository_relative_path, gl_project_name) def initialize(shard_name, repository_relative_path, gl_project_path)
@shard_name = shard_name @shard_name = shard_name
@repository_relative_path = repository_relative_path @repository_relative_path = repository_relative_path
@output = '' @output = ''
@gl_project_name = gl_project_name @gl_project_path = gl_project_path
end end
def import_project(source, _timeout) def import_project(source, _timeout)
raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_name) raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_path)
Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source) Gitlab::GitalyClient::RepositoryService.new(raw_repository).import_repository(source)
true true
...@@ -434,7 +434,7 @@ module Gitlab ...@@ -434,7 +434,7 @@ module Gitlab
def fork_repository(new_shard_name, new_repository_relative_path, new_project_name) def fork_repository(new_shard_name, new_repository_relative_path, new_project_name)
target_repository = Gitlab::Git::Repository.new(new_shard_name, new_repository_relative_path, nil, new_project_name) target_repository = Gitlab::Git::Repository.new(new_shard_name, new_repository_relative_path, nil, new_project_name)
raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_name) raw_repository = Gitlab::Git::Repository.new(shard_name, repository_relative_path, nil, gl_project_path)
Gitlab::GitalyClient::RepositoryService.new(target_repository).fork_repository(raw_repository) Gitlab::GitalyClient::RepositoryService.new(target_repository).fork_repository(raw_repository)
rescue GRPC::BadStatus => e rescue GRPC::BadStatus => e
......
...@@ -7,7 +7,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -7,7 +7,7 @@ describe Gitlab::GitalyClient::Util do
let(:gl_repository) { 'project-1' } let(:gl_repository) { 'project-1' }
let(:git_object_directory) { '.git/objects' } let(:git_object_directory) { '.git/objects' }
let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] } let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] }
let(:gl_project_name) { 'namespace/myproject' } let(:gl_project_path) { 'namespace/myproject' }
let(:git_env) do let(:git_env) do
{ {
'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory, 'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory,
...@@ -16,7 +16,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -16,7 +16,7 @@ describe Gitlab::GitalyClient::Util do
end end
subject do subject do
described_class.repository(repository_storage, relative_path, gl_repository, gl_project_name) described_class.repository(repository_storage, relative_path, gl_repository, gl_project_path)
end end
it 'creates a Gitaly::Repository with the given data' do it 'creates a Gitaly::Repository with the given data' do
...@@ -28,7 +28,7 @@ describe Gitlab::GitalyClient::Util do ...@@ -28,7 +28,7 @@ describe Gitlab::GitalyClient::Util do
expect(subject.gl_repository).to eq(gl_repository) expect(subject.gl_repository).to eq(gl_repository)
expect(subject.git_object_directory).to eq(git_object_directory) expect(subject.git_object_directory).to eq(git_object_directory)
expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory) expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory)
expect(subject.gl_project_name).to eq(gl_project_name) expect(subject.gl_project_path).to eq(gl_project_path)
end end
end end
end end
...@@ -2291,7 +2291,7 @@ describe Repository do ...@@ -2291,7 +2291,7 @@ describe Repository do
expect(subject).to be_a(Gitlab::Git::Repository) expect(subject).to be_a(Gitlab::Git::Repository)
expect(subject.relative_path).to eq(project.disk_path + '.git') expect(subject.relative_path).to eq(project.disk_path + '.git')
expect(subject.gl_repository).to eq("project-#{project.id}") expect(subject.gl_repository).to eq("project-#{project.id}")
expect(subject.gl_project_name).to eq(project.full_path) expect(subject.gl_project_path).to eq(project.full_path)
end end
context 'with a wiki repository' do context 'with a wiki repository' do
...@@ -2301,7 +2301,7 @@ describe Repository do ...@@ -2301,7 +2301,7 @@ describe Repository do
expect(subject).to be_a(Gitlab::Git::Repository) expect(subject).to be_a(Gitlab::Git::Repository)
expect(subject.relative_path).to eq(project.disk_path + '.wiki.git') expect(subject.relative_path).to eq(project.disk_path + '.wiki.git')
expect(subject.gl_repository).to eq("wiki-#{project.id}") expect(subject.gl_repository).to eq("wiki-#{project.id}")
expect(subject.gl_project_name).to eq(project.full_path) expect(subject.gl_project_path).to eq(project.full_path)
end end
end end
end end
......
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