diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/services/groups | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/create_service.rb | 4 | ||||
-rw-r--r-- | app/services/groups/import_export/export_service.rb | 24 | ||||
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 34 | ||||
-rw-r--r-- | app/services/groups/update_service.rb | 1 |
4 files changed, 52 insertions, 11 deletions
diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb index 8cc31200689..eb1b8d4fcc0 100644 --- a/app/services/groups/create_service.rb +++ b/app/services/groups/create_service.rb @@ -38,6 +38,10 @@ module Groups # overridden in EE end + def remove_unallowed_params + params.delete(:default_branch_protection) unless can?(current_user, :create_group_with_default_branch_protection) + end + def create_chat_team? Gitlab.config.mattermost.enabled && @chat_team && group.chat_team.nil? end diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb index f8715b57d6e..0f2e3bb65f9 100644 --- a/app/services/groups/import_export/export_service.rb +++ b/app/services/groups/import_export/export_service.rb @@ -52,11 +52,11 @@ module Groups end def savers - [tree_exporter, file_saver] + [version_saver, tree_exporter, file_saver] end def tree_exporter - Gitlab::ImportExport::Group::LegacyTreeSaver.new( + tree_exporter_class.new( group: @group, current_user: @current_user, shared: @shared, @@ -64,6 +64,18 @@ module Groups ) end + def tree_exporter_class + if ::Feature.enabled?(:group_export_ndjson, @group&.parent, default_enabled: true) + Gitlab::ImportExport::Group::TreeSaver + else + Gitlab::ImportExport::Group::LegacyTreeSaver + end + end + + def version_saver + Gitlab::ImportExport::VersionSaver.new(shared: shared) + end + def file_saver Gitlab::ImportExport::Saver.new(exportable: @group, shared: @shared) end @@ -84,6 +96,8 @@ module Groups group_name: @group.name, message: 'Group Import/Export: Export succeeded' ) + + notification_service.group_was_exported(@group, @current_user) end def notify_error @@ -93,6 +107,12 @@ module Groups error: @shared.errors.join(', '), message: 'Group Import/Export: Export failed' ) + + notification_service.group_was_not_exported(@group, @current_user, @shared.errors) + end + + def notification_service + @notification_service ||= NotificationService.new end end end diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index f62b9d3c8a6..6f692c98c38 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -27,18 +27,34 @@ module Groups private def import_file - @import_file ||= Gitlab::ImportExport::FileImporter.import(importable: @group, - archive_file: nil, - shared: @shared) + @import_file ||= Gitlab::ImportExport::FileImporter.import( + importable: @group, + archive_file: nil, + shared: @shared + ) end def restorer - @restorer ||= Gitlab::ImportExport::Group::LegacyTreeRestorer.new( - user: @current_user, - shared: @shared, - group: @group, - group_hash: nil - ) + @restorer ||= + if ndjson? + Gitlab::ImportExport::Group::TreeRestorer.new( + user: @current_user, + shared: @shared, + group: @group + ) + else + Gitlab::ImportExport::Group::LegacyTreeRestorer.new( + user: @current_user, + shared: @shared, + group: @group, + group_hash: nil + ) + end + end + + def ndjson? + ::Feature.enabled?(:group_import_ndjson, @group&.parent, default_enabled: true) && + File.exist?(File.join(@shared.export_path, 'tree/groups/_all.ndjson')) end def remove_import_file diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 8635b82461b..948540619ae 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -66,6 +66,7 @@ module Groups # overridden in EE def remove_unallowed_params params.delete(:emails_disabled) unless can?(current_user, :set_emails_disabled, group) + params.delete(:default_branch_protection) unless can?(current_user, :update_default_branch_protection, group) end def valid_share_with_group_lock_change? |