BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
771f7351
Commit
771f7351
authored
Jun 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
few more modifications based on comments
parent
e2c95c07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
import_export.rb
lib/gitlab/import_export.rb
+4
-0
import_export_reader.rb
lib/gitlab/import_export/import_export_reader.rb
+8
-7
No files found.
lib/gitlab/import_export.rb
View file @
771f7351
...
@@ -20,6 +20,10 @@ module Gitlab
...
@@ -20,6 +20,10 @@ module Gitlab
"project.bundle"
"project.bundle"
end
end
def
config_file
'lib/gitlab/import_export/import_export.yml'
end
def
version_filename
def
version_filename
'VERSION'
'VERSION'
end
end
...
...
lib/gitlab/import_export/import_export_reader.rb
View file @
771f7351
...
@@ -2,17 +2,18 @@ module Gitlab
...
@@ -2,17 +2,18 @@ module Gitlab
module
ImportExport
module
ImportExport
class
ImportExportReader
class
ImportExportReader
def
initialize
(
config:
'lib/gitlab/import_export/import_export.yml'
,
shared
:)
def
initialize
(
shared
:)
config
=
ImportExport
.
config_file
@shared
=
shared
@shared
=
shared
config_hash
=
YAML
.
load_file
(
config
).
deep_symbolize_keys
config_hash
=
YAML
.
load_file
(
config
).
deep_symbolize_keys
@tree
=
config_hash
[
:project_tree
]
@tree
=
config_hash
[
:project_tree
]
@attributes_
pars
er
=
Gitlab
::
ImportExport
::
AttributesFinder
.
new
(
included_attributes:
config_hash
[
:included_attributes
],
@attributes_
find
er
=
Gitlab
::
ImportExport
::
AttributesFinder
.
new
(
included_attributes:
config_hash
[
:included_attributes
],
excluded_attributes:
config_hash
[
:excluded_attributes
],
excluded_attributes:
config_hash
[
:excluded_attributes
],
methods:
config_hash
[
:methods
])
methods:
config_hash
[
:methods
])
end
end
def
project_tree
def
project_tree
@attributes_
pars
er
.
find_included
(
:project
).
merge
(
include:
build_hash
(
@tree
))
@attributes_
find
er
.
find_included
(
:project
).
merge
(
include:
build_hash
(
@tree
))
rescue
=>
e
rescue
=>
e
@shared
.
error
(
e
.
message
)
@shared
.
error
(
e
.
message
)
false
false
...
@@ -25,7 +26,7 @@ module Gitlab
...
@@ -25,7 +26,7 @@ module Gitlab
if
model_objects
.
is_a?
(
Hash
)
if
model_objects
.
is_a?
(
Hash
)
build_json_config_hash
(
model_objects
)
build_json_config_hash
(
model_objects
)
else
else
@attributes_
pars
er
.
find
(
model_objects
)
@attributes_
find
er
.
find
(
model_objects
)
end
end
end
end
end
end
...
@@ -36,7 +37,7 @@ module Gitlab
...
@@ -36,7 +37,7 @@ module Gitlab
model_object_hash
.
values
.
flatten
.
each
do
|
model_object
|
model_object_hash
.
values
.
flatten
.
each
do
|
model_object
|
current_key
=
model_object_hash
.
keys
.
first
current_key
=
model_object_hash
.
keys
.
first
@attributes_
pars
er
.
parse
(
current_key
)
{
|
hash
|
@json_config_hash
[
current_key
]
||=
hash
}
@attributes_
find
er
.
parse
(
current_key
)
{
|
hash
|
@json_config_hash
[
current_key
]
||=
hash
}
handle_model_object
(
current_key
,
model_object
)
handle_model_object
(
current_key
,
model_object
)
process_sub_model
(
current_key
,
model_object
)
if
model_object
.
is_a?
(
Hash
)
process_sub_model
(
current_key
,
model_object
)
if
model_object
.
is_a?
(
Hash
)
...
@@ -66,14 +67,14 @@ module Gitlab
...
@@ -66,14 +67,14 @@ module Gitlab
def
create_model_value
(
current_key
,
value
)
def
create_model_value
(
current_key
,
value
)
parsed_hash
=
{
include:
value
}
parsed_hash
=
{
include:
value
}
@attributes_
pars
er
.
parse
(
value
)
do
|
hash
|
@attributes_
find
er
.
parse
(
value
)
do
|
hash
|
parsed_hash
=
{
include:
hash_or_merge
(
value
,
hash
)
}
parsed_hash
=
{
include:
hash_or_merge
(
value
,
hash
)
}
end
end
@json_config_hash
[
current_key
]
=
parsed_hash
@json_config_hash
[
current_key
]
=
parsed_hash
end
end
def
add_model_value
(
current_key
,
value
)
def
add_model_value
(
current_key
,
value
)
@attributes_
pars
er
.
parse
(
value
)
{
|
hash
|
value
=
{
value
=>
hash
}
}
@attributes_
find
er
.
parse
(
value
)
{
|
hash
|
value
=
{
value
=>
hash
}
}
old_values
=
@json_config_hash
[
current_key
][
:include
]
old_values
=
@json_config_hash
[
current_key
][
:include
]
@json_config_hash
[
current_key
][
:include
]
=
([
old_values
]
+
[
value
]).
compact
.
flatten
@json_config_hash
[
current_key
][
:include
]
=
([
old_values
]
+
[
value
]).
compact
.
flatten
end
end
...
...
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