summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/relation_tree_saver.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 21:06:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 21:06:20 +0000
commit0c3f12149372a79b825d265a6c28dc547e4a1afc (patch)
tree43bdaa20afb0b061d09c56d8507efd51d28601be /lib/gitlab/import_export/relation_tree_saver.rb
parentff67e3ed08355fb2d6f6e69d4ed06cd09052e573 (diff)
downloadgitlab-ce-0c3f12149372a79b825d265a6c28dc547e4a1afc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/import_export/relation_tree_saver.rb')
-rw-r--r--lib/gitlab/import_export/relation_tree_saver.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/relation_tree_saver.rb b/lib/gitlab/import_export/relation_tree_saver.rb
new file mode 100644
index 00000000000..a0452071ccf
--- /dev/null
+++ b/lib/gitlab/import_export/relation_tree_saver.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module ImportExport
+ class RelationTreeSaver
+ include Gitlab::ImportExport::CommandLineUtil
+
+ def serialize(exportable, relations_tree)
+ if Feature.enabled?(:export_fast_serialize, default_enabled: true)
+ Gitlab::ImportExport::FastHashSerializer
+ .new(exportable, relations_tree)
+ .execute
+ else
+ exportable.as_json(relations_tree)
+ end
+ end
+
+ def save(tree, dir_path, filename)
+ mkdir_p(dir_path)
+
+ tree_json = JSON.generate(tree)
+
+ File.write(File.join(dir_path, filename), tree_json)
+ end
+ end
+ end
+end