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>2020-03-17 12:09:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-17 12:09:20 +0300
commitfc1df8c8307fc5022f9e8aae04164c089d8fdf2e (patch)
treea759f58abf9e41200c48a60de73c84cab47a250d /lib/gitlab/import_export/group
parentc8df22c555ab707a705e57c4257fd3ed1ce7c3b0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/import_export/group')
-rw-r--r--lib/gitlab/import_export/group/tree_restorer.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/gitlab/import_export/group/tree_restorer.rb b/lib/gitlab/import_export/group/tree_restorer.rb
index cbaa6929efa..247e39a68b9 100644
--- a/lib/gitlab/import_export/group/tree_restorer.rb
+++ b/lib/gitlab/import_export/group/tree_restorer.rb
@@ -17,9 +17,17 @@ module Gitlab
end
def restore
- @tree_hash = @group_hash || read_tree_hash
- @group_members = @tree_hash.delete('members')
- @children = @tree_hash.delete('children')
+ @relation_reader ||=
+ if @group_hash.present?
+ ImportExport::JSON::LegacyReader::User.new(@group_hash, reader.group_relation_names)
+ else
+ ImportExport::JSON::LegacyReader::File.new(@path, reader.group_relation_names)
+ end
+
+ @group_members = @relation_reader.consume_relation('members')
+ @children = @relation_reader.consume_attribute('children')
+ @relation_reader.consume_attribute('name')
+ @relation_reader.consume_attribute('path')
if members_mapper.map && restorer.restore
@children&.each do |group_hash|
@@ -45,21 +53,12 @@ module Gitlab
private
- def read_tree_hash
- json = IO.read(@path)
- ActiveSupport::JSON.decode(json)
- rescue => e
- @shared.error(e)
-
- raise Gitlab::ImportExport::Error.new('Incorrect JSON format')
- end
-
def restorer
@relation_tree_restorer ||= RelationTreeRestorer.new(
user: @user,
shared: @shared,
importable: @group,
- tree_hash: @tree_hash.except('name', 'path'),
+ relation_reader: @relation_reader,
members_mapper: members_mapper,
object_builder: object_builder,
relation_factory: relation_factory,