This instance was upgraded to Heptapod 0.27.2 on 2021-12-08 at 22:00 UTC+1

Commit 651707ca authored by James Lopez's avatar James Lopez
Browse files

refactor code to use new import type

parent 61ad3ca24e61
......@@ -679,6 +679,10 @@ def safe_import_url
Gitlab::UrlSanitizer.new(import_url).masked_url
end
def bare_repository_import?
import_type == 'bare_repository'
end
def gitlab_project_import?
import_type == 'gitlab_project'
end
......
......@@ -12,7 +12,6 @@ def execute
forked_from_project_id = params.delete(:forked_from_project_id)
import_data = params.delete(:import_data)
@skip_wiki = params.delete(:skip_wiki)
@skip_import = params.delete(:skip_import)
@project = Project.new(params)
......@@ -88,7 +87,7 @@ def allowed_namespace?(user, namespace_id)
def after_create_actions
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
if !@project.gitlab_project_import? || @skip_import
unless @project.gitlab_project_import?
@project.create_wiki unless skip_wiki?
create_services_from_active_templates(@project)
......@@ -121,7 +120,7 @@ def save_project_and_import_data(import_data)
Project.transaction do
@project.create_or_update_import_data(data: import_data[:data], credentials: import_data[:credentials]) if import_data
if @project.save && !@project.import?
if @project.save && !@project.import? && !@project.bare_repository_import?
raise 'Failed to create repository' unless @project.create_repository
end
end
......@@ -166,7 +165,7 @@ def set_project_name_from_path
def import_schedule
if @project.errors.empty?
@project.import_schedule if @project.import? && !@skip_import
@project.import_schedule if @project.import?
else
fail(error: @project.errors.full_messages.join(', '))
end
......
......@@ -56,8 +56,7 @@ def create_project
path: project_name,
skip_disk_validation: true,
skip_wiki: bare_repo.wiki_exists?,
skip_import: true,
import_type: 'gitlab_project',
import_type: 'bare_repository',
namespace_id: group&.id).execute
if project.persisted? && mv_repo(project)
......
......@@ -169,7 +169,7 @@
FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.wiki.git"))
expect(Projects::CreateService).to receive(:new).with(admin, hash_including(skip_wiki: true,
skip_import: true)).and_call_original
import_type: 'bare_repository')).and_call_original
importer.create_project_if_needed
......
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