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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
2a7a1bcc
Commit
2a7a1bcc
authored
Mar 10, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored methods in project tree restorer
parent
e90b1e14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
app/services/projects/import_export/project_tree_restorer.rb
app/services/projects/import_export/project_tree_restorer.rb
+10
-6
No files found.
app/services/projects/import_export/project_tree_restorer.rb
View file @
2a7a1bcc
...
...
@@ -13,19 +13,23 @@ module Projects
def
restore
json
=
IO
.
read
(
@path
)
tree_hash
=
ActiveSupport
::
JSON
.
decode
(
json
)
project_params
=
tree_hash
.
reject
{
|
_key
,
value
|
value
.
is_a?
(
Array
)
}
project
=
Projects
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project
.
save
relation_hash
=
{}
project
=
create_project
(
tree_hash
)
ImportExport
.
project_tree
.
each
do
|
relation
|
next
if
tree_hash
[
relation
.
to_s
].
empty?
relation_hash
[
relation
.
to_s
]
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
],
project
.
id
)
project
.
update_attribute
(
relation
,
relation_hash
[
relation
.
to_s
]
)
relation_hash
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
],
project
.
id
)
project
.
update_attribute
(
relation
,
relation_hash
)
end
end
private
def
create_project
(
tree_hash
)
project_params
=
tree_hash
.
reject
{
|
_key
,
value
|
value
.
is_a?
(
Array
)
}
project
=
Projects
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project
.
save
project
end
def
create_relation
(
relation
,
relation_hash_list
,
project_id
)
relation_hash_list
.
map
do
|
relation_hash
|
Projects
::
ImportExport
::
RelationFactory
.
create
(
...
...
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