diff options
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/sh-import-repos-fix-9-5.yml | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/import.rake | 3 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/projects/create_service_spec.rb | 9 |
5 files changed, 28 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index c80e706234a..b2a75d2b332 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -77,6 +77,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 @@ -993,6 +994,7 @@ class Project < ActiveRecord::Base # Check if repository already exists on disk def can_create_repository? + return true if skip_disk_validation return false unless repository_storage_path if gitlab_shell.exists?(repository_storage_path, "#{build_full_path}.git") diff --git a/changelogs/unreleased/sh-import-repos-fix-9-5.yml b/changelogs/unreleased/sh-import-repos-fix-9-5.yml new file mode 100644 index 00000000000..082a0c7282d --- /dev/null +++ b/changelogs/unreleased/sh-import-repos-fix-9-5.yml @@ -0,0 +1,4 @@ +--- +title: Fix gitlab rake:import:repos task +merge_request: +author: diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake index 48bd9139ce8..a7cb3242251 100644 --- a/lib/tasks/gitlab/import.rake +++ b/lib/tasks/gitlab/import.rake @@ -39,7 +39,8 @@ namespace :gitlab do project_params = { name: name, - path: name + path: name, + skip_disk_validation: true } # find group namespace diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 98861c8c81a..f55d287445c 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1650,6 +1650,17 @@ describe Project do end end + describe '#can_create_repository?' 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.can_create_repository?).to be_truthy + end + end + describe '#latest_successful_builds_for' do def create_pipeline(status = 'success') create(:ci_pipeline, project: project, diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index dbf3c49c67d..95ff976e198 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -208,6 +208,15 @@ describe Projects::CreateService, '#execute' do end end + 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 + end + end + def create_project(user, opts) Projects::CreateService.new(user, opts).execute end |