Write project full path to .git/config when creating projects

We'd need to keep track of project full path otherwise directory tree created with hashed storage enabled cannot be usefully imported using the import rake task.
This commit is contained in:
Douglas Barbosa Alexandre 2017-12-19 14:36:33 -02:00
parent 946a3634bc
commit 9504a529b7
3 changed files with 16 additions and 0 deletions

View File

@ -1432,6 +1432,11 @@ class Project < ActiveRecord::Base
Gitlab::PagesTransfer.new.rename_project(path_before_change, self.path, namespace.full_path)
end
def write_repository_config(key, value, prefix: :gitlab)
key = [prefix, key].compact.join('.')
repo.config[key] = value
end
def rename_repo_notify!
send_move_instructions(full_path_was)
expires_full_path_cache

View File

@ -87,6 +87,11 @@ module Projects
def after_create_actions
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
@project.write_repository_config(:fullpath, @project.full_path)
unless @project.gitlab_project_import?
@project.create_wiki unless skip_wiki?
create_services_from_active_templates(@project)

View File

@ -252,6 +252,12 @@ describe Projects::CreateService, '#execute' do
end
end
it 'writes project full path to .git/config' do
project = create_project(user, opts)
expect(project.repo.config['gitlab.fullpath']).to eq project.full_path
end
def create_project(user, opts)
Projects::CreateService.new(user, opts).execute
end