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
6398fc95
Commit
6398fc95
authored
Apr 08, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
6666aeb1
f15caf01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
1 deletion
+79
-1
changelogs/unreleased/fix-pull-request-importer.yml
changelogs/unreleased/fix-pull-request-importer.yml
+5
-0
lib/gitlab/import/merge_request_helpers.rb
lib/gitlab/import/merge_request_helpers.rb
+1
-1
spec/lib/gitlab/import/merge_request_helpers_spec.rb
spec/lib/gitlab/import/merge_request_helpers_spec.rb
+73
-0
No files found.
changelogs/unreleased/fix-pull-request-importer.yml
0 → 100644
View file @
6398fc95
---
title
:
Improve performance of PR import
merge_request
:
27121
author
:
type
:
performance
lib/gitlab/import/merge_request_helpers.rb
View file @
6398fc95
...
...
@@ -22,7 +22,7 @@ module Gitlab
# additional work that is strictly necessary.
merge_request_id
=
insert_and_return_id
(
attributes
,
project
.
merge_requests
)
merge_request
=
project
.
merge_requests
.
re
load
.
find
(
merge_request_id
)
merge_request
=
project
.
merge_requests
.
re
set
.
find
(
merge_request_id
)
[
merge_request
,
false
]
end
...
...
spec/lib/gitlab/import/merge_request_helpers_spec.rb
0 → 100644
View file @
6398fc95
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Import
::
MergeRequestHelpers
,
type: :helper
do
set
(
:project
)
{
create
(
:project
,
:repository
)
}
set
(
:user
)
{
create
(
:user
)
}
describe
'.create_merge_request_without_hooks'
do
let
(
:iid
)
{
42
}
let
(
:attributes
)
do
{
iid:
iid
,
title:
'My Pull Request'
,
description:
'This is my pull request'
,
source_project_id:
project
.
id
,
target_project_id:
project
.
id
,
source_branch:
'master-42'
,
target_branch:
'master'
,
state: :merged
,
author_id:
user
.
id
,
assignee_id:
user
.
id
}
end
subject
{
helper
.
create_merge_request_without_hooks
(
project
,
attributes
,
iid
)
}
context
'when merge request does not exist'
do
it
'returns a new object'
do
expect
(
subject
.
first
).
not_to
be_nil
expect
(
subject
.
second
).
to
eq
(
false
)
end
it
'does load all existing objects'
do
5
.
times
do
|
iid
|
MergeRequest
.
create!
(
attributes
.
merge
(
iid:
iid
,
source_branch:
iid
.
to_s
))
end
# does ensure that we only load object twice
# 1. by #insert_and_return_id
# 2. by project.merge_requests.find
expect_any_instance_of
(
MergeRequest
).
to
receive
(
:attributes
)
.
twice
.
times
.
and_call_original
expect
(
subject
.
first
).
not_to
be_nil
expect
(
subject
.
second
).
to
eq
(
false
)
end
end
context
'when merge request does exist'
do
before
do
MergeRequest
.
create!
(
attributes
)
end
it
'returns an existing object'
do
expect
(
subject
.
first
).
not_to
be_nil
expect
(
subject
.
second
).
to
eq
(
true
)
end
end
context
'when project is deleted'
do
before
do
project
.
delete
end
it
'returns an existing object'
do
expect
(
subject
.
first
).
to
be_nil
end
end
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