Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ebe7c4c8
Commit
ebe7c4c8
authored
Oct 02, 2019
by
Aleksei Lipniagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag and comments on hash structure
parent
334a9775
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
lib/gitlab/import_export/fast_hash_serializer.rb
lib/gitlab/import_export/fast_hash_serializer.rb
+11
-1
lib/gitlab/import_export/project_tree_saver.rb
lib/gitlab/import_export/project_tree_saver.rb
+2
-0
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+5
-0
No files found.
lib/gitlab/import_export/fast_hash_serializer.rb
View file @
ebe7c4c8
...
...
@@ -79,6 +79,11 @@ module Gitlab
@tree
=
tree
end
# With the usage of `JSONBatchRelation`, it returns partially
# serialized hash which is not easily accessible.
# It means you can only manipulate and replace top-level objects.
# All future mutations of the hash (such as `fix_project_tree`)
# should be aware of that.
def
execute
simple_serialize
.
merge
(
serialize_includes
)
end
...
...
@@ -131,7 +136,12 @@ module Gitlab
data
=
[]
record
.
in_batches
(
of:
@batch_size
)
do
|
batch
|
# rubocop:disable Cop/InBatches
data
.
append
(
JSONBatchRelation
.
new
(
batch
,
options
,
preloads
[
key
]).
tap
(
&
:raw_json
))
if
Feature
.
enabled?
(
:export_fast_serialize_with_raw_json
,
default_enabled:
true
)
data
.
append
(
JSONBatchRelation
.
new
(
batch
,
options
,
preloads
[
key
]).
tap
(
&
:raw_json
))
else
batch
=
batch
.
preload
(
preloads
[
key
])
if
preloads
&
.
key?
(
key
)
data
+=
batch
.
as_json
(
options
)
end
end
data
...
...
lib/gitlab/import_export/project_tree_saver.rb
View file @
ebe7c4c8
...
...
@@ -31,6 +31,8 @@ module Gitlab
private
# Aware that the resulting hash needs to be pure-hash and
# does not include any AR objects anymore, only objects that run `.to_json`
def
fix_project_tree
(
project_tree
)
if
@params
[
:description
].
present?
project_tree
[
'description'
]
=
@params
[
:description
]
...
...
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
View file @
ebe7c4c8
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
FastHashSerializer
do
# FastHashSerializer#execute generates the hash which is not easily accessible
# and includes `JSONBatchRelation` items which are serialized at this point.
# Wrapping the result into JSON generating/parsing is for making
# the testing more convenient. Doing this, we can check that
# all items are properly serialized while traversing the simple hash.
subject
{
JSON
.
parse
(
JSON
.
generate
(
described_class
.
new
(
project
,
tree
).
execute
))
}
let!
(
:project
)
{
setup_project
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment