Commit 78f7c3c8 authored by Stan Hu's avatar Stan Hu 🔴

Fix gitlab:import:repos Rake task moving repositories into the wrong location

If the source import directory were different from the destination directory,
GitLab would first create a blank repository and then erroneously move the
original one into a subdirectory. Adding an import type prevents this the project
from being initialized in the first place. It was accidentally removed in

Closes #40765
parent 806a68a8
Pipeline #14902495 failed with stages
in 60 minutes and 20 seconds
title: Fix gitlab:import:repos Rake task moving repositories into the wrong location
type: fixed
......@@ -55,6 +55,7 @@ module Gitlab
name: project_name,
path: project_name,
skip_disk_validation: true,
import_type: 'gitlab_project',
namespace_id: group&.id).execute
if project.persisted? && mv_repo(project)
......@@ -132,6 +132,20 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
expect(File).to exist(File.join(project.repository_storage_path, project.disk_path + '.git'))
it 'moves an existing project to the correct path' do
project = create(:project, :repository)
original_commit_count = project.repository.commit_count
bare_repo =, project.repository.path)
gitlab_importer =, bare_repo)
expect(gitlab_importer).to receive(:create_project).and_call_original
new_project = gitlab_importer.create_project_if_needed
expect(new_project.repository.commit_count).to eq(original_commit_count)
context 'with Wiki' do
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment