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
Tatuya Kamada
gitlab-ce
Commits
f4d762d7
Commit
f4d762d7
authored
Jun 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressing MR feedback, few changes to members mapper
parent
e5cf4cd7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+10
-15
No files found.
lib/gitlab/import_export/members_mapper.rb
View file @
f4d762d7
...
@@ -10,29 +10,18 @@ module Gitlab
...
@@ -10,29 +10,18 @@ module Gitlab
@project
=
project
@project
=
project
@note_member_list
=
[]
@note_member_list
=
[]
# This needs to run first, as second call would be from
generate_
map
# This needs to run first, as second call would be from
#
map
# which means project members already exist.
# which means project members already exist.
ensure_default_member!
ensure_default_member!
end
end
def
map
def
map
@map
||=
generate_map
end
def
default_user_id
@user
.
id
end
private
def
generate_map
@map
||=
@map
||=
begin
begin
@exported_members
.
inject
(
missing_keys_tracking_hash
)
do
|
hash
,
member
|
@exported_members
.
inject
(
missing_keys_tracking_hash
)
do
|
hash
,
member
|
existing_user
=
User
.
where
(
find_project_user_query
(
member
)).
first
existing_user
=
User
.
where
(
find_project_user_query
(
member
)).
first
old_user_id
=
member
[
'user'
][
'id'
]
old_user_id
=
member
[
'user'
][
'id'
]
if
existing_user
&&
add_user_as_team_member
(
existing_user
,
member
)
.
persisted?
if
existing_user
&&
add_user_as_team_member
(
existing_user
,
member
)
hash
[
old_user_id
]
=
existing_user
.
id
hash
[
old_user_id
]
=
existing_user
.
id
end
end
hash
hash
...
@@ -40,10 +29,16 @@ module Gitlab
...
@@ -40,10 +29,16 @@ module Gitlab
end
end
end
end
def
default_user_id
@user
.
id
end
private
def
missing_keys_tracking_hash
def
missing_keys_tracking_hash
Hash
.
new
do
|
_
,
key
|
Hash
.
new
do
|
_
,
key
|
@note_member_list
<<
key
@note_member_list
<<
key
@user
.
id
default_user_
id
end
end
end
end
...
@@ -54,7 +49,7 @@ module Gitlab
...
@@ -54,7 +49,7 @@ module Gitlab
def
add_user_as_team_member
(
existing_user
,
member
)
def
add_user_as_team_member
(
existing_user
,
member
)
member
[
'user'
]
=
existing_user
member
[
'user'
]
=
existing_user
ProjectMember
.
create
(
member_hash
(
member
))
ProjectMember
.
create
(
member_hash
(
member
))
.
persisted?
end
end
def
member_hash
(
member
)
def
member_hash
(
member
)
...
...
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