diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/bulk_imports | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/bulk_imports')
-rw-r--r-- | app/models/bulk_imports/entity.rb | 15 |
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 |