diff options
Diffstat (limited to 'app/models/bulk_imports/entity.rb')
-rw-r--r-- | app/models/bulk_imports/entity.rb | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/app/models/bulk_imports/entity.rb b/app/models/bulk_imports/entity.rb index ebca5e90313..6fc24c77f1d 100644 --- a/app/models/bulk_imports/entity.rb +++ b/app/models/bulk_imports/entity.rb @@ -39,9 +39,28 @@ class BulkImports::Entity < ApplicationRecord validates :project, absence: true, if: :group validates :group, absence: true, if: :project - validates :source_type, :source_full_path, :destination_name, presence: true - validates :destination_namespace, exclusion: [nil], if: :group - validates :destination_namespace, presence: true, if: :project + validates :source_type, presence: true + validates :source_full_path, + presence: true, + format: { with: Gitlab::Regex.bulk_import_source_full_path_regex, + message: Gitlab::Regex.bulk_import_destination_namespace_path_regex_message } + + validates :destination_name, + presence: true, + format: { with: Gitlab::Regex.group_path_regex, + message: Gitlab::Regex.group_path_regex_message } + + validates :destination_namespace, + exclusion: [nil], + format: { with: Gitlab::Regex.bulk_import_destination_namespace_path_regex, + message: Gitlab::Regex.bulk_import_destination_namespace_path_regex_message }, + if: :group + + validates :destination_namespace, + presence: true, + format: { with: Gitlab::Regex.bulk_import_destination_namespace_path_regex, + message: Gitlab::Regex.bulk_import_destination_namespace_path_regex_message }, + if: :project validate :validate_parent_is_a_group, if: :parent validate :validate_imported_entity_type @@ -57,6 +76,10 @@ class BulkImports::Entity < ApplicationRecord alias_attribute :destination_slug, :destination_name + delegate :default_project_visibility, + :default_group_visibility, + to: :'Gitlab::CurrentSettings.current_application_settings' + state_machine :status, initial: :created do state :created, value: 0 state :started, value: 1 @@ -156,6 +179,12 @@ class BulkImports::Entity < ApplicationRecord project? ? project&.full_path : group&.full_path end + def default_visibility_level + return default_group_visibility if group? + + default_project_visibility + end + private def validate_parent_is_a_group |