Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 13:34:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 13:34:06 +0300
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/bulk_imports/entity.rb
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/bulk_imports/entity.rb')
-rw-r--r--app/models/bulk_imports/entity.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/bulk_imports/entity.rb b/app/models/bulk_imports/entity.rb
index a4d0b7485ba..16224fde502 100644
--- a/app/models/bulk_imports/entity.rb
+++ b/app/models/bulk_imports/entity.rb
@@ -43,6 +43,8 @@ class BulkImports::Entity < ApplicationRecord
validate :validate_parent_is_a_group, if: :parent
validate :validate_imported_entity_type
+ validate :validate_destination_namespace_ascendency, if: :group_entity?
+
enum source_type: { group_entity: 0, project_entity: 1 }
state_machine :status, initial: :created do
@@ -107,4 +109,17 @@ class BulkImports::Entity < ApplicationRecord
)
end
end
+
+ def validate_destination_namespace_ascendency
+ source = Group.find_by_full_path(source_full_path)
+
+ return unless source
+
+ if source.self_and_descendants.any? { |namespace| namespace.full_path == destination_namespace }
+ errors.add(
+ :destination_namespace,
+ s_('BulkImport|destination group cannot be part of the source group tree')
+ )
+ end
+ end
end