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
cc061cd1
Commit
cc061cd1
authored
Jun 20, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some more edge cases
parent
4e9b094b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
21 deletions
+13
-21
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+10
-5
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+3
-16
No files found.
lib/gitlab/import_export/relation_factory.rb
View file @
cc061cd1
...
...
@@ -80,8 +80,7 @@ module Gitlab
case
@relation_name
when
:merge_request_diff_files
then
setup_diff
when
:notes
then
setup_note
when
:milestone
,
:milestones
,
:project_label
,
:project_labels
then
setup_project_group
when
*
(
EXISTING_OBJECT_CHECK
-
[
:project_feature
])
then
setup_project_group
when
'Ci::Pipeline'
then
setup_pipeline
else
@relation_hash
[
'project_id'
]
=
@project
.
id
...
...
@@ -275,7 +274,11 @@ module Gitlab
end
def
find_or_create_object!
finder_hash
=
parsed_relation_hash
.
slice
(
'title'
,
'project_id'
,
'group_id'
)
# Can't use IDs as validation exists calilng `.group` or `.project`
finder_hash
=
{
project:
@project
}.
tap
do
|
hash
|
hash
[
:group
]
=
@project
.
group
if
relation_class
.
attribute_method?
(
'group_id'
)
hash
[
:title
]
=
parsed_relation_hash
[
'title'
]
if
parsed_relation_hash
[
'title'
]
end
if
label?
label
=
GroupProjectFinder
.
find_or_new
(
Label
,
finder_hash
)
...
...
@@ -288,8 +291,10 @@ module Gitlab
object
=
GroupProjectFinder
.
find_or_create
(
relation_class
,
finder_hash
)
if
milestone?
parsed_relation_hash
.
delete
(
'group_id'
)
if
object
.
project_id
parsed_relation_hash
.
delete
(
'project_id'
)
if
object
.
group_id
parsed_relation_hash
.
delete
(
'group_id'
)
if
object
.
project
parsed_relation_hash
.
delete
(
'project_id'
)
if
object
.
group
parsed_relation_hash
.
delete
(
'iid'
)
parsed_relation_hash
.
delete
(
'id'
)
end
object
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
cc061cd1
...
...
@@ -246,13 +246,6 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect
(
project
.
issues
.
size
).
to
eq
(
results
.
fetch
(
:issues
,
0
))
end
it
'has issue with group label and project label'
do
labels
=
project
.
issues
.
first
.
labels
expect
(
labels
.
where
(
type:
"ProjectLabel"
).
count
).
to
eq
(
results
.
fetch
(
:first_issue_labels
,
0
))
expect
(
labels
.
where
(
type:
"ProjectLabel"
).
where
.
not
(
group_id:
nil
).
count
).
to
eq
(
0
)
end
it
'does not set params that are excluded from import_export settings'
do
expect
(
project
.
import_type
).
to
be_nil
expect
(
project
.
creator_id
).
not_to
eq
123
...
...
@@ -268,12 +261,6 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
it
'has group milestone'
do
expect
(
project
.
group
.
milestones
.
size
).
to
eq
(
results
.
fetch
(
:milestones
,
0
))
end
it
'has issue with group label'
do
labels
=
project
.
issues
.
first
.
labels
expect
(
labels
.
where
(
type:
"GroupLabel"
).
count
).
to
eq
(
results
.
fetch
(
:first_issue_labels
,
0
))
end
end
context
'Light JSON'
do
...
...
@@ -360,12 +347,12 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
it_behaves_like
'restores project correctly'
,
issues:
2
,
labels:
1
,
milestones:
1
,
milestones:
2
,
first_issue_labels:
1
it_behaves_like
'restores group correctly'
,
labels:
1
,
milestones:
1
,
labels:
0
,
milestones:
0
,
first_issue_labels:
1
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