summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-09-29 17:20:56 -0700
committerStan Hu <stanhu@gmail.com>2017-10-02 08:51:37 -0700
commitbac29160302549c3c651991bf839b304a9e1c8b4 (patch)
tree24355af64eadbf70abcb58991b4225f8c2860be4 /app
parentb40192a9464503bf4b141f8cf6133d7ba0f893fe (diff)
downloadgitlab-ce-bac29160302549c3c651991bf839b304a9e1c8b4.tar.gz
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 command-line. Closes #37682
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index bb3f74c4b89..44d1190cc5b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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 @@ class Project < ActiveRecord::Base
end
# 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