Update project full path in .git/config when transfering a project

parent 64fe954d
......@@ -75,6 +75,8 @@ module Projects
project.old_path_with_namespace = @old_path
project.expires_full_path_cache
write_repository_config(@new_path)
execute_system_hooks
end
rescue Exception # rubocop:disable Lint/RescueException
......@@ -98,6 +100,13 @@ module Projects
project.save!
end
def write_repository_config(full_path)
# 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, full_path)
end
def refresh_permissions
# This ensures we only schedule 1 job for every user that has access to
# the namespaces.
......@@ -110,6 +119,7 @@ module Projects
def rollback_side_effects
rollback_folder_move
update_namespace_and_visibility(@old_namespace)
write_repository_config(@old_path)
end
def rollback_folder_move
......
......@@ -54,6 +54,12 @@ describe Projects::TransferService do
expect(project.disk_path).not_to eq(old_path)
expect(project.disk_path).to start_with(group.path)
end
it 'updates project full path in .git/config' do
transfer_project(project, user, group)
expect(project.repo.config['gitlab.fullpath']).to eq "#{group.full_path}/#{project.path}"
end
end
context 'when transfer fails' do
......@@ -86,6 +92,12 @@ describe Projects::TransferService do
expect(original_path).to eq current_path
end
it 'rolls back project full path in .git/config' do
attempt_project_transfer
expect(project.repo.config['gitlab.fullpath']).to eq project.full_path
end
it "doesn't send move notifications" do
expect_any_instance_of(NotificationService).not_to receive(:project_was_moved)
......
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