BigW Consortium Gitlab

Commit b5ac9ea0 by Douwe Maan Committed by Tiago Botelho

Merge branch '41424-gitlab-rake-gitlab-import-repos-schedules-an-import' into 'master'

Resolve "gitlab-rake gitlab:import:repos schedules an import" Closes #41424 See merge request gitlab-org/gitlab-ce!16115
parent f4502a1a
......@@ -639,7 +639,7 @@ class Project < ActiveRecord::Base
end
def import?
external_import? || forked? || gitlab_project_import?
external_import? || forked? || gitlab_project_import? || bare_repository_import?
end
def no_import?
......@@ -679,6 +679,10 @@ class Project < ActiveRecord::Base
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
......
......@@ -56,11 +56,7 @@ module Projects
after_create_actions if @project.persisted?
if @project.errors.empty?
@project.import_schedule if @project.import?
else
fail(error: @project.errors.full_messages.join(', '))
end
import_schedule
@project
rescue ActiveRecord::RecordInvalid => e
......@@ -164,5 +160,15 @@ module Projects
@project.path = @project.name.dup.parameterize
end
end
private
def import_schedule
if @project.errors.empty?
@project.import_schedule if @project.import? && !@project.bare_repository_import?
else
fail(error: @project.errors.full_messages.join(', '))
end
end
end
end
---
title: Fix gitlab-rake gitlab:import:repos import schedule
merge_request: 16115
author:
type: fixed
......@@ -55,7 +55,8 @@ module Gitlab
name: project_name,
path: project_name,
skip_disk_validation: true,
import_type: 'gitlab_project',
skip_wiki: bare_repo.wiki_exists?,
import_type: 'bare_repository',
namespace_id: group&.id).execute
if project.persisted? && mv_repo(project)
......
......@@ -7,6 +7,7 @@ module Gitlab
module ImportSources
ImportSource = Struct.new(:name, :title, :importer)
# We exclude `bare_repository` here as it has no import class associated
ImportTable = [
ImportSource.new('github', 'GitHub', Gitlab::GithubImport::ParallelImporter),
ImportSource.new('bitbucket', 'Bitbucket', Gitlab::BitbucketImport::Importer),
......
......@@ -141,6 +141,7 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
project = Project.find_by_full_path("#{admin.full_path}/#{project_path}")
expect(File).to exist(File.join(project.repository_storage_path, project.disk_path + '.git'))
expect(File).to exist(File.join(project.repository_storage_path, project.disk_path + '.wiki.git'))
end
it 'moves an existing project to the correct path' do
......@@ -171,6 +172,9 @@ 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}.wiki.git"))
expect(Projects::CreateService).to receive(:new).with(admin, hash_including(skip_wiki: true,
import_type: 'bare_repository')).and_call_original
importer.create_project_if_needed
project = Project.find_by_full_path(project_path)
......
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