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
d677d17d
Commit
d677d17d
authored
Feb 20, 2020
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Group Import owner access level
parent
de715ec8
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
138 deletions
+173
-138
changelogs/unreleased/georgekoltsov-fix-group-members-owner-access-level.yml
...ed/georgekoltsov-fix-group-members-owner-access-level.yml
+5
-0
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+9
-3
spec/lib/gitlab/import_export/members_mapper_spec.rb
spec/lib/gitlab/import_export/members_mapper_spec.rb
+159
-135
No files found.
changelogs/unreleased/georgekoltsov-fix-group-members-owner-access-level.yml
0 → 100644
View file @
d677d17d
---
title
:
Fix an issue with Group Import members with Owner access level being imported with Maintainer access level. Owner access level is now preserved
merge_request
:
25595
author
:
type
:
fixed
lib/gitlab/import_export/members_mapper.rb
View file @
d677d17d
...
@@ -51,7 +51,7 @@ module Gitlab
...
@@ -51,7 +51,7 @@ module Gitlab
@importable
.
members
.
destroy_all
# rubocop: disable DestroyAll
@importable
.
members
.
destroy_all
# rubocop: disable DestroyAll
relation_class
.
create!
(
user:
@user
,
access_level:
relation_class
::
MAINTAINER
,
source_id:
@importable
.
id
,
importing:
true
)
relation_class
.
create!
(
user:
@user
,
access_level:
highest_access_level
,
source_id:
@importable
.
id
,
importing:
true
)
rescue
=>
e
rescue
=>
e
raise
e
,
"Error adding importer user to
#{
@importable
.
class
}
members.
#{
e
.
message
}
"
raise
e
,
"Error adding importer user to
#{
@importable
.
class
}
members.
#{
e
.
message
}
"
end
end
...
@@ -59,7 +59,7 @@ module Gitlab
...
@@ -59,7 +59,7 @@ module Gitlab
def
user_already_member?
def
user_already_member?
member
=
@importable
.
members
&
.
first
member
=
@importable
.
members
&
.
first
member
&
.
user
==
@user
&&
member
.
access_level
>=
relation_class
::
MAINTAINER
member
&
.
user
==
@user
&&
member
.
access_level
>=
highest_access_level
end
end
def
add_team_member
(
member
,
existing_user
=
nil
)
def
add_team_member
(
member
,
existing_user
=
nil
)
...
@@ -72,7 +72,7 @@ module Gitlab
...
@@ -72,7 +72,7 @@ module Gitlab
parsed_hash
(
member
).
merge
(
parsed_hash
(
member
).
merge
(
'source_id'
=>
@importable
.
id
,
'source_id'
=>
@importable
.
id
,
'importing'
=>
true
,
'importing'
=>
true
,
'access_level'
=>
[
member
[
'access_level'
],
relation_class
::
MAINTAINER
].
min
'access_level'
=>
[
member
[
'access_level'
],
highest_access_level
].
min
).
except
(
'user_id'
)
).
except
(
'user_id'
)
end
end
...
@@ -97,6 +97,12 @@ module Gitlab
...
@@ -97,6 +97,12 @@ module Gitlab
GroupMember
GroupMember
end
end
end
end
def
highest_access_level
return
relation_class
::
OWNER
if
relation_class
==
GroupMember
relation_class
::
MAINTAINER
end
end
end
end
end
end
end
spec/lib/gitlab/import_export/members_mapper_spec.rb
View file @
d677d17d
This diff is collapsed.
Click to expand it.
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