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
4e9b094b
Commit
4e9b094b
authored
Jun 20, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor finder
parent
825c68e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
lib/gitlab/import_export/group_project_finder.rb
lib/gitlab/import_export/group_project_finder.rb
+13
-9
No files found.
lib/gitlab/import_export/group_project_finder.rb
View file @
4e9b094b
...
...
@@ -2,18 +2,22 @@ module Gitlab
module
ImportExport
class
GroupProjectFinder
def
self
.
find_or_new
(
*
args
)
new
(
*
args
).
find_or_new
Project
.
transaction
do
new
(
*
args
).
find_or_new
end
end
def
self
.
find_or_create
(
*
args
)
new
(
*
args
).
find_or_create
Project
.
transaction
do
new
(
*
args
).
find_or_create
end
end
def
initialize
(
klass
,
attributes
)
@klass
=
klass
@attributes
=
attributes
@group
_id
=
@attributes
[
'group_id'
]
@project
_id
=
@attributes
[
'project_id'
]
@group
=
@attributes
[
:group
]
@project
=
@attributes
[
:project
]
end
def
find_or_new
...
...
@@ -27,11 +31,11 @@ module Gitlab
private
def
where_clause
@attributes
.
except
(
'group_id'
,
'project_id'
).
map
do
|
key
,
value
|
project_clause
=
table
[
key
].
eq
(
value
).
and
(
table
[
:project_id
].
eq
(
@project
_
id
))
@attributes
.
except
(
:group
,
:project
).
map
do
|
key
,
value
|
project_clause
=
table
[
key
].
eq
(
value
).
and
(
table
[
:project_id
].
eq
(
@project
.
id
))
if
@group
_id
project_clause
.
or
(
table
[
key
].
eq
(
value
).
and
(
table
[
:group_id
].
eq
(
@group_
id
)))
if
@group
project_clause
.
or
(
table
[
key
].
eq
(
value
).
and
(
table
[
:group_id
].
eq
(
@group
.
id
)))
else
project_clause
end
...
...
@@ -43,7 +47,7 @@ module Gitlab
end
def
project_attributes
@attributes
.
except
(
'group_id'
).
tap
do
|
atts
|
@attributes
.
except
(
:group
).
tap
do
|
atts
|
atts
[
'type'
]
=
'ProjectLabel'
if
label?
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