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
Jérome Perrin
gitlab-ce
Commits
efde96e9
Commit
efde96e9
authored
Apr 06, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started refactored the dynamic rules to be defined in a yml file
parent
e05bc611
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
app/services/projects/import_export/import_export.yml
app/services/projects/import_export/import_export.yml
+31
-0
app/services/projects/import_export/import_export_reader.rb
app/services/projects/import_export/import_export_reader.rb
+47
-0
No files found.
app/services/projects/import_export/import_export.yml
0 → 100644
View file @
efde96e9
# Class relationships to be included in the import/export
:project_tree:
- :issues
- :labels
- :milestones
- :snippets
- :releases
- :events
- :project_members:
- :user
- :merge_requests:
- :merge_request_diff
- :commit_statuses:
- :commit
:attributes_only:
:project:
- :name
- :path
- :description
- :issues_enabled
- :wall_enabled
- :merge_requests_enabled
- :wiki_enabled
- :snippets_enabled
- :visibility_level
- :archived
:user:
- :id
- :email
- :username
\ No newline at end of file
app/services/projects/import_export/import_export_reader.rb
0 → 100644
View file @
efde96e9
module
Projects
module
ImportExport
module
ImportExportReader
extend
self
def
project_tree
{
only:
atts_only
[
:project
],
include:
build_hash
(
tree
)
}
end
def
config
@config
||=
YAML
.
load_file
(
'app/services/projects/import_export/import_export.yml'
)
end
def
atts_only
config
[
:attributes_only
]
end
def
atts_except
config
[
:attributes_except
]
end
def
tree
config
[
:project_tree
]
end
def
build_hash
(
array
)
array
.
map
{
|
el
|
el
.
is_a?
(
Hash
)
?
process_include
(
el
)
:
el
}
end
def
process_include
(
hash
)
included_classes_hash
=
{}
hash
.
values
.
flatten
.
each
do
|
value
|
value
=
value
.
is_a?
(
Hash
)
?
process_include
(
hash
)
:
value
new_hash
=
{
:include
=>
value
}
new_hash
.
merge!
(
check_only
(
value
))
included_classes_hash
[
hash
.
keys
.
first
]
=
new_hash
end
included_classes_hash
end
def
check_only
(
value
)
key
=
value
.
is_a?
(
Hash
)
?
value
.
keys
.
first
:
value
atts_only
[
key
].
nil?
?
{}
:
{
only:
atts_only
[
key
]
}
end
end
end
end
\ No newline at end of file
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