This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-26 at 14:30 UTC+2 (a few minutes of down time)

Commit bac29160 authored by Stan Hu's avatar Stan Hu
Browse files

Fix gitlab-rake gitlab:import:repos task

Because of a change in GitLab 9.5.4 to prevent users from assuming control of
a repository already on disk, the import task broke. Imports would fail with
the message, "There is already a repository with that name on disk".

This change skips the validation when the import is done from the

Closes #37682
parent 4062fb51b25d
......@@ -72,6 +72,7 @@ class Project < ActiveRecord::Base
attr_accessor :old_path_with_namespace
attr_accessor :template_name
attr_writer :pipeline_status
attr_accessor :skip_disk_validation
alias_attribute :title, :name
......@@ -227,7 +228,7 @@ class Project < ActiveRecord::Base
validates :import_url, importable_url: true, if: [:external_import?, :import_url_changed?]
validates :star_count, numericality: { greater_than_or_equal_to: 0 }
validate :check_limit, on: :create
validate :can_create_repository?, on: [:create, :update], if: ->(project) { !project.persisted? || project.renamed? }
validate :check_repository_path_availability, on: [:create, :update], if: ->(project) { !project.persisted? || project.renamed? }
validate :avatar_type,
if: ->(project) { project.avatar.present? && project.avatar_changed? }
validates :avatar, file_size: { maximum: 200.kilobytes.to_i }
......@@ -1018,7 +1019,8 @@ def expire_caches_before_rename(old_path)
# Check if repository already exists on disk
def can_create_repository?
def check_repository_path_availability
return true if skip_disk_validation
return false unless repository_storage_path
expires_full_path_cache # we need to clear cache to validate renames correctly
title: Fix gitlab-rake gitlab:import:repos task failing
type: fixed
......@@ -56,7 +56,8 @@ def create_project
name: project_path,
path: project_path,
repository_storage: storage_name,
namespace_id: group&.id
namespace_id: group&.id,
skip_disk_validation: true
project =, project_params).execute
......@@ -2793,6 +2793,17 @@ def enable_lfs
describe '#check_repository_path_availability' do
let(:project) { build(:project) }
it 'skips gitlab-shell exists?' do
project.skip_disk_validation = true
expect(project.gitlab_shell).not_to receive(:exists?)
expect(project.check_repository_path_availability).to be_truthy
describe '#latest_successful_pipeline_for_default_branch' do
let(:project) { build(:project) }
......@@ -209,6 +209,15 @@
context 'when skip_disk_validation is used' do
it 'sets the project attribute' do
opts[:skip_disk_validation] = true
project = create_project(user, opts)
expect(project.skip_disk_validation).to be_truthy
def create_project(user, opts), opts).execute
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