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
f04e9dad
Commit
f04e9dad
authored
Aug 05, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support pending invitation project members importing projects
parent
685c048d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+8
-5
spec/lib/gitlab/import_export/members_mapper_spec.rb
spec/lib/gitlab/import_export/members_mapper_spec.rb
+20
-0
No files found.
CHANGELOG
View file @
f04e9dad
...
...
@@ -73,6 +73,7 @@ v 8.11.0 (unreleased)
- Add description to new_issue email and new_merge_request_email in text/plain content type. !5663 (dixpac)
- Speed up and reduce memory usage of Commit#repo_changes, Repository#expire_avatar_cache and IrkerWorker
- Add unfold links for Side-by-Side view. !5415 (Tim Masliuchenko)
- Adds support for pending invitation project members importing projects
v 8.10.5 (unreleased)
...
...
lib/gitlab/import_export/members_mapper.rb
View file @
f04e9dad
...
...
@@ -18,11 +18,14 @@ module Gitlab
@map
||=
begin
@exported_members
.
inject
(
missing_keys_tracking_hash
)
do
|
hash
,
member
|
existing_user
=
User
.
where
(
find_project_user_query
(
member
)).
first
if
member
[
'user'
]
old_user_id
=
member
[
'user'
][
'id'
]
if
existing_user
&&
add_user_as_team_member
(
existing_user
,
member
)
hash
[
old_user_id
]
=
existing_user
.
id
existing_user
=
User
.
where
(
find_project_user_query
(
member
)).
first
hash
[
old_user_id
]
=
existing_user
.
id
if
existing_user
&&
add_team_member
(
member
,
existing_user
)
else
add_team_member
(
member
)
end
hash
end
end
...
...
@@ -45,7 +48,7 @@ module Gitlab
ProjectMember
.
create!
(
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
.
id
,
importing:
true
)
end
def
add_
user_as_team_member
(
existing_user
,
member
)
def
add_
team_member
(
member
,
existing_user
=
nil
)
member
[
'user'
]
=
existing_user
ProjectMember
.
create
(
member_hash
(
member
)).
persisted?
...
...
spec/lib/gitlab/import_export/members_mapper_spec.rb
View file @
f04e9dad
...
...
@@ -26,6 +26,20 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
"email"
=>
user2
.
email
,
"username"
=>
user2
.
username
}
},
{
"id"
=>
3
,
"access_level"
=>
40
,
"source_id"
=>
14
,
"source_type"
=>
"Project"
,
"user_id"
=>
nil
,
"notification_level"
=>
3
,
"created_at"
=>
"2016-03-11T10:21:44.822Z"
,
"updated_at"
=>
"2016-03-11T10:21:44.822Z"
,
"created_by_id"
=>
1
,
"invite_email"
=>
'invite@test.com'
,
"invite_token"
=>
'token'
,
"invite_accepted_at"
=>
nil
}]
end
...
...
@@ -47,5 +61,11 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
expect
(
members_mapper
.
missing_author_ids
.
first
).
to
eq
(
-
1
)
end
it
'has invited members with no user'
do
members_mapper
.
map
expect
(
ProjectMember
.
find_by_invite_email
(
'invite@test.com'
)).
not_to
be_nil
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