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
ec3acf86
Commit
ec3acf86
authored
Nov 12, 2019
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use only iis for quering merge request
parent
99fc1d06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
20 deletions
+8
-20
lib/gitlab/import_export/group_project_object_builder.rb
lib/gitlab/import_export/group_project_object_builder.rb
+2
-10
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+1
-5
spec/lib/gitlab/import_export/group_project_object_builder_spec.rb
...gitlab/import_export/group_project_object_builder_spec.rb
+5
-5
No files found.
lib/gitlab/import_export/group_project_object_builder.rb
View file @
ec3acf86
...
...
@@ -50,11 +50,11 @@ module Gitlab
].
compact
end
# Returns Arel clause `"{table_name}"."project_id" = {project.id}`
# Returns Arel clause `"{table_name}"."project_id" = {project.id}`
if project is present
# or, if group is present:
# `"{table_name}"."project_id" = {project.id} OR "{table_name}"."group_id" = {group.id}`
def
where_clause_base
clause
=
table
[
project_column
].
eq
(
project
.
id
)
clause
=
table
[
:project_id
].
eq
(
project
.
id
)
if
project
clause
=
clause
.
or
(
table
[
:group_id
].
eq
(
group
.
id
))
if
group
clause
...
...
@@ -108,14 +108,6 @@ module Gitlab
klass
==
MergeRequest
end
def
project_column
if
@original_klass
.
reflect_on_association
(
:project
)
||
label?
:project_id
elsif
klass
.
reflect_on_association
(
:target_project
)
:target_project_id
end
end
# If an existing group milestone used the IID
# claim the IID back and set the group milestone to use one available
# This is necessary to fix situations like the following:
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
ec3acf86
...
...
@@ -332,16 +332,12 @@ module Gitlab
# Can't use IDs as validation exists calling `group` or `project` attributes
finder_hash
=
parsed_relation_hash
.
tap
do
|
hash
|
hash
[
'group'
]
=
@project
.
group
if
relation_class
.
attribute_method?
(
'group_id'
)
hash
[
'project'
]
=
@project
if
re
flect_on_project_association?
hash
[
'project'
]
=
@project
if
re
lation_class
.
reflect_on_association
(
:project
)
hash
.
delete
(
'project_id'
)
end
GroupProjectObjectBuilder
.
build
(
relation_class
,
finder_hash
)
end
def
reflect_on_project_association?
relation_class
.
reflect_on_association
(
:project
)
||
relation_class
.
reflect_on_association
(
:target_project
)
end
end
end
end
spec/lib/gitlab/import_export/group_project_object_builder_spec.rb
View file @
ec3acf86
...
...
@@ -55,23 +55,23 @@ describe Gitlab::ImportExport::GroupProjectObjectBuilder do
merge_request
=
create
(
:merge_request
,
title:
'MergeRequest'
,
iid:
7
,
target_project:
project
,
source_project:
project
)
expect
(
described_class
.
build
(
MergeRequest
,
'title'
=>
'MergeRequest'
,
'project'
=>
project
,
'source_project_id'
=>
project
.
id
,
'target_project_id'
=>
project
.
id
,
'source_branch'
=>
'SourceBranch'
,
'iid'
=>
7
,
'target_branch'
=>
'TargetBranch'
,
'author
'
=>
project
.
creator
)).
to
eq
(
merge_request
)
'author
_id'
=>
project
.
creator
.
id
)).
to
eq
(
merge_request
)
end
it
'creates a new merge_request'
do
merge_request
=
described_class
.
build
(
MergeRequest
,
'title'
=>
'MergeRequest'
,
'project'
=>
project
,
'iid'
=>
8
,
'source_project'
=>
project
,
'source_project_id'
=>
project
.
id
,
'target_project_id'
=>
project
.
id
,
'source_branch'
=>
'SourceBranch'
,
'target_branch'
=>
'TargetBranch'
,
'author
'
=>
project
.
creator
)
'author
_id'
=>
project
.
creator
.
id
)
expect
(
merge_request
.
persisted?
).
to
be
true
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