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>2023-06-20 13:43:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
commit3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch)
tree3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /lib/gitlab/import_export/group
parent9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff)
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'lib/gitlab/import_export/group')
-rw-r--r--lib/gitlab/import_export/group/import_export.yml1
-rw-r--r--lib/gitlab/import_export/group/tree_restorer.rb29
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/gitlab/import_export/group/import_export.yml b/lib/gitlab/import_export/group/import_export.yml
index e30414265be..c2a1a1f8575 100644
--- a/lib/gitlab/import_export/group/import_export.yml
+++ b/lib/gitlab/import_export/group/import_export.yml
@@ -56,7 +56,6 @@ excluded_attributes:
- :runners_token
- :runners_token_encrypted
- :saml_discovery_token
- - :visibility_level
- :trial_ends_on
- :shared_runners_minute_limit
- :extra_shared_runners_minutes_limit
diff --git a/lib/gitlab/import_export/group/tree_restorer.rb b/lib/gitlab/import_export/group/tree_restorer.rb
index 19d707aaca5..0b92942eb8a 100644
--- a/lib/gitlab/import_export/group/tree_restorer.rb
+++ b/lib/gitlab/import_export/group/tree_restorer.rb
@@ -65,6 +65,15 @@ module Gitlab
# with existing groups name and/or path.
group_attributes.delete_attributes('name', 'path')
+ if @top_level_group.has_parent?
+ group_attributes.attributes['visibility_level'] = sub_group_visibility_level(
+ group_attributes.attributes['visibility_level'],
+ @top_level_group.parent
+ )
+ elsif Gitlab::VisibilityLevel.restricted_level?(group_attributes.attributes['visibility_level'])
+ group_attributes.delete_attribute('visibility_level')
+ end
+
restore_group(@top_level_group, group_attributes)
end
@@ -86,6 +95,7 @@ module Gitlab
parent_id = group_attributes.delete_attribute('parent_id')
name = group_attributes.delete_attribute('name')
path = group_attributes.delete_attribute('path')
+ visibility_level = group_attributes.delete_attribute('visibility_level')
parent_group = @groups_mapping.fetch(parent_id) { raise(ArgumentError, 'Parent group not found') }
@@ -94,7 +104,7 @@ module Gitlab
name: name,
path: path,
parent_id: parent_group.id,
- visibility_level: sub_group_visibility_level(group_attributes.attributes, parent_group)
+ visibility_level: sub_group_visibility_level(visibility_level, parent_group)
).execute
group.validate!
@@ -124,16 +134,23 @@ module Gitlab
end
end
- def sub_group_visibility_level(group_hash, parent_group)
- original_visibility_level = group_hash['visibility_level'] || Gitlab::VisibilityLevel::PRIVATE
+ def sub_group_visibility_level(visibility_level, parent_group)
+ parent_visibility_level = parent_group.visibility_level
- if parent_group && parent_group.visibility_level < original_visibility_level
- Gitlab::VisibilityLevel.closest_allowed_level(parent_group.visibility_level)
+ original_visibility_level = visibility_level ||
+ closest_allowed_level(parent_visibility_level)
+
+ if parent_visibility_level < original_visibility_level
+ closest_allowed_level(parent_visibility_level)
else
- original_visibility_level
+ closest_allowed_level(original_visibility_level)
end
end
+ def closest_allowed_level(visibility_level)
+ Gitlab::VisibilityLevel.closest_allowed_level(visibility_level)
+ end
+
def reader
strong_memoize(:reader) do
Gitlab::ImportExport::Reader.new(