diff options
-rw-r--r-- | changelogs/unreleased/fix-import-member-access.yml | 5 | ||||
-rw-r--r-- | doc/user/project/settings/import_export.md | 1 | ||||
-rw-r--r-- | lib/gitlab/import_export/members_mapper.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/members_mapper_spec.rb | 7 |
4 files changed, 18 insertions, 1 deletions
diff --git a/changelogs/unreleased/fix-import-member-access.yml b/changelogs/unreleased/fix-import-member-access.yml new file mode 100644 index 00000000000..5dc4ae738f8 --- /dev/null +++ b/changelogs/unreleased/fix-import-member-access.yml @@ -0,0 +1,5 @@ +--- +title: Fix issue importing members with owner access +merge_request: 28636 +author: +type: fixed diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md index 89008fd15b9..db4f8fbd8d3 100644 --- a/doc/user/project/settings/import_export.md +++ b/doc/user/project/settings/import_export.md @@ -23,6 +23,7 @@ > in the import side is required to map the users, based on email or username. > Otherwise, a supplementary comment is left to mention the original author and > the MRs, notes or issues will be owned by the importer. +> - Project members with owner access will get imported as maintainers. > - Control project Import/Export with the [API](../../../api/project_import_export.md). > - If an imported project contains merge requests originated from forks, > then new branches associated with such merge requests will be created diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb index 6be95a16513..5ab5059165e 100644 --- a/lib/gitlab/import_export/members_mapper.rb +++ b/lib/gitlab/import_export/members_mapper.rb @@ -59,7 +59,11 @@ module Gitlab end def member_hash(member) - parsed_hash(member).merge('source_id' => @project.id, 'importing' => true) + parsed_hash(member).merge( + 'source_id' => @project.id, + 'importing' => true, + 'access_level' => [member['access_level'], ProjectMember::MAINTAINER].min + ) end def parsed_hash(member) diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb index 67e4c289906..c663cf42a83 100644 --- a/spec/lib/gitlab/import_export/members_mapper_spec.rb +++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb @@ -73,6 +73,13 @@ describe Gitlab::ImportExport::MembersMapper do expect(user2.authorized_project?(project)).to be true end + it 'maps an owner as a maintainer' do + exported_members.first['access_level'] = ProjectMember::OWNER + + expect(members_mapper.map[exported_user_id]).to eq(user2.id) + expect(ProjectMember.find_by_user_id(user2.id).access_level).to eq(ProjectMember::MAINTAINER) + end + context 'user is not an admin' do let(:user) { create(:user) } |