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
Boxiang Sun
gitlab-ce
Commits
a28be02e
Commit
a28be02e
authored
Apr 08, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
starting to use the new dynamic stuff on the import
parent
d29c816d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
app/services/projects/import_export/import_export_reader.rb
app/services/projects/import_export/import_export_reader.rb
+4
-4
app/services/projects/import_export/project_tree_restorer.rb
app/services/projects/import_export/project_tree_restorer.rb
+28
-19
No files found.
app/services/projects/import_export/import_export_reader.rb
View file @
a28be02e
...
...
@@ -7,6 +7,10 @@ module Projects
{
only:
atts_only
[
:project
],
include:
build_hash
(
tree
)
}
end
def
tree
config
[
:project_tree
]
end
private
def
config
...
...
@@ -21,10 +25,6 @@ module Projects
config
[
:attributes_except
]
end
def
tree
config
[
:project_tree
]
end
def
build_hash
(
array
)
array
.
map
do
|
el
|
if
el
.
is_a?
(
Hash
)
...
...
app/services/projects/import_export/project_tree_restorer.rb
View file @
a28be02e
...
...
@@ -25,32 +25,41 @@ module Projects
#TODO Definitely refactor this method!
#TODO Think about having a yaml file to describe the tree instead of just hashes?
def
create_relations
(
relation_list
=
default_relation_list
,
tree_hash
=
@tree_hash
)
members_map
# TODO remove this and fix project_members
relation_list
.
each
do
|
relation
|
relation_hash
=
nil
# FIXME
# next if tree_hash[relation.to_s].blank?
if
(
relation
.
is_a?
(
Hash
)
&&
relation
.
values
.
first
[
:include
])
#TODO name stuff properly
relation_sym
=
relation
.
keys
.
first
#TODO remove sub-relation hashes from here so we can save the parent relation first
relation_hash
=
create_relation
(
relation_sym
,
tree_hash
[
relation_sym
.
to_s
])
sub_relations
=
[]
sub_relation
=
relation
.
values
.
first
[
:include
]
sub_relation_hash_list
=
tree_hash
[
relation
.
keys
.
first
.
to_s
]
sub_relation_hash_list
.
each
do
|
sub_relation_hash
|
sub_relations
<<
create_relation
(
relation
,
sub_relation_hash
[
relation
.
to_s
])
if
relation
.
is_a?
(
Hash
)
relation
.
values
.
each
do
|
value
|
create_relations
(
value
,
@tree_hash
[
relation
.
to_s
])
end
relation_hash
.
update_attribute
(
sub_relation
,
sub_relations
)
end
relation_hash
||
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
])
relation_hash
=
create_relation
(
relation
,
tree_hash
[
relation
.
to_s
])
project
.
update_attribute
(
relation
,
relation_hash
)
# relation_hash = nil
# # FIXME
# # next if tree_hash[relation.to_s].blank?
# if (relation.is_a?(Hash) && relation.values.first[:include])
# #TODO name stuff properly
# relation_sym = relation.keys.first
# #TODO remove sub-relation hashes from here so we can save the parent relation first
# relation_hash = create_relation(relation_sym, tree_hash[relation_sym.to_s])
# sub_relations = []
# sub_relation = relation.values.first[:include]
# sub_relation_hash_list = tree_hash[relation.keys.first.to_s]
# sub_relation_hash_list.each do |sub_relation_hash|
# sub_relations << create_relation(relation, sub_relation_hash[relation.to_s])
# end
# relation_hash.update_attribute(sub_relation, sub_relations)
# end
# relation_hash ||= create_relation(relation, tree_hash[relation.to_s])
# project.update_attribute(relation, relation_hash)
end
end
def
default_relation_list
ImportExport
.
project_tree
.
reject
do
|
rel
|
rel
.
is_a?
(
Hash
)
&&
!
rel
[
:project_members
].
blank?
end
Projects
::
ImportExport
::
ImportExportReader
.
tree
# ImportExport.project_tree.reject do |rel|
# rel.is_a?(Hash) && !rel[:project_members].blank?
# end
end
def
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