Fix import scheduled on bare repo import

This commit is contained in:
James Lopez 2017-12-22 17:21:13 +01:00
parent ac35636f4a
commit 02276f7a70
3 changed files with 12 additions and 1 deletions

View file

@ -12,6 +12,7 @@ module Projects
forked_from_project_id = params.delete(:forked_from_project_id) forked_from_project_id = params.delete(:forked_from_project_id)
import_data = params.delete(:import_data) import_data = params.delete(:import_data)
@skip_wiki = params.delete(:skip_wiki) @skip_wiki = params.delete(:skip_wiki)
@skip_import = params.delete(:skip_import)
@project = Project.new(params) @project = Project.new(params)
@ -57,7 +58,7 @@ module Projects
after_create_actions if @project.persisted? after_create_actions if @project.persisted?
if @project.errors.empty? if @project.errors.empty?
@project.import_schedule if @project.import? @project.import_schedule if @project.import? && !@skip_import
else else
fail(error: @project.errors.full_messages.join(', ')) fail(error: @project.errors.full_messages.join(', '))
end end

View file

@ -55,6 +55,8 @@ module Gitlab
name: project_name, name: project_name,
path: project_name, path: project_name,
skip_disk_validation: true, skip_disk_validation: true,
skip_wiki: bare_repo.wiki_exists?,
skip_import: true,
import_type: 'gitlab_project', import_type: 'gitlab_project',
namespace_id: group&.id).execute namespace_id: group&.id).execute

View file

@ -68,6 +68,12 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
expect(Project.find_by_full_path(project_path)).not_to be_nil expect(Project.find_by_full_path(project_path)).not_to be_nil
end end
it 'does not schedule an import' do
expect_any_instance_of(Project).not_to receive(:import_schedule)
importer.create_project_if_needed
end
it 'creates the Git repo in disk' do it 'creates the Git repo in disk' do
FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.git")) FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.git"))
@ -161,6 +167,8 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.git")) FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.git"))
FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.wiki.git")) FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.wiki.git"))
expect(Projects::CreateService).to receive(:new).with(admin, hash_including(skip_import: true)).and_call_original
importer.create_project_if_needed importer.create_project_if_needed
project = Project.find_by_full_path(project_path) project = Project.find_by_full_path(project_path)