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
6e641789
Commit
6e641789
authored
Sep 24, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix null pipeline problem
parent
4c8d2232
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+14
-1
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+2
-1
spec/lib/gitlab/import_export/project.json
spec/lib/gitlab/import_export/project.json
+2
-1
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+1
-1
No files found.
lib/gitlab/import_export/project_tree_restorer.rb
View file @
6e641789
...
...
@@ -136,9 +136,18 @@ module Gitlab
return
if
tree_hash
[
relation_key
].
blank?
tree_array
=
[
tree_hash
[
relation_key
]].
flatten
null_iid_pipelines
=
[]
# Avoid keeping a possible heavy object in memory once we are done with it
while
relation_item
=
tree_array
.
shift
while
relation_item
=
(
tree_array
.
shift
||
null_iid_pipelines
.
shift
)
if
nil_iid_pipeline?
(
relation_key
,
relation_item
)
&&
tree_array
.
any?
# Move pipelines with NULL IIDs to the end
# so they don't clash with existing IIDs.
null_iid_pipelines
<<
relation_item
next
end
# The transaction at this level is less speedy than one single transaction
# But we can't have it in the upper level or GC won't get rid of the AR objects
# after we save the batch.
...
...
@@ -201,6 +210,10 @@ module Gitlab
def
excluded_keys_for_relation
(
relation
)
reader
.
attributes_finder
.
find_excluded_keys
(
relation
)
end
def
nil_iid_pipeline?
(
relation_key
,
relation_item
)
relation_key
==
'pipelines'
&&
relation_item
[
'iid'
].
nil?
end
end
end
end
lib/gitlab/import_export/relation_factory.rb
View file @
6e641789
...
...
@@ -86,7 +86,6 @@ module Gitlab
case
@relation_name
when
:merge_request_diff_files
then
setup_diff
when
:notes
then
setup_note
when
'Ci::Pipeline'
then
setup_pipeline
end
update_user_references
...
...
@@ -94,6 +93,8 @@ module Gitlab
update_group_references
remove_duplicate_assignees
setup_pipeline
if
@relation_name
==
'Ci::Pipeline'
reset_tokens!
remove_encrypted_attributes!
end
...
...
spec/lib/gitlab/import_export/project.json
View file @
6e641789
...
...
@@ -6143,7 +6143,7 @@
"id"
:
36
,
"project_id"
:
5
,
"ref"
:
"master"
,
"sha"
:
"
be93687618e4b132087f430a4d8fc3a609c9b77c
"
,
"sha"
:
"
sha-notes
"
,
"before_sha"
:
null
,
"push_data"
:
null
,
"created_at"
:
"2016-03-22T15:20:35.755Z"
,
...
...
@@ -6353,6 +6353,7 @@
},
{
"id"
:
38
,
"iid"
:
1
,
"project_id"
:
5
,
"ref"
:
"master"
,
"sha"
:
"5f923865dde3436854e9ceb9cdb7815618d4e849"
,
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
6e641789
...
...
@@ -59,7 +59,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
it
'creates a valid pipeline note'
do
expect
(
Ci
::
Pipeline
.
fi
rst
.
notes
).
not_to
be_empty
expect
(
Ci
::
Pipeline
.
fi
nd_by_sha
(
'sha-notes'
)
.
notes
).
not_to
be_empty
end
it
'restores pipelines with missing ref'
do
...
...
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