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
Boxiang Sun
gitlab-ce
Commits
2e1decd0
Commit
2e1decd0
authored
May 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restricted actual member mapping to admins
parent
1eb802cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
17 deletions
+26
-17
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+10
-10
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+4
-2
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+12
-5
No files found.
lib/gitlab/import_export/members_mapper.rb
View file @
2e1decd0
...
...
@@ -18,6 +18,16 @@ module Gitlab
@map
=
generate_map
end
def
default_project_member
@default_project_member
||=
begin
return
@project
.
project_members
.
first
.
user
.
id
unless
@project
.
project_members
.
empty?
default_member
=
ProjectMember
.
new
(
default_project_member_hash
)
default_member
.
save!
default_member
.
user
.
id
end
end
private
def
generate_map
...
...
@@ -39,16 +49,6 @@ module Gitlab
member
.
except
(
'id'
).
merge
(
source_id:
@project
.
id
)
end
def
default_project_member
@default_project_member
||=
begin
return
@project
.
project_members
.
first
.
user
.
id
unless
@project
.
project_members
.
empty?
default_member
=
ProjectMember
.
new
(
default_project_member_hash
)
default_member
.
save!
default_member
.
user
.
id
end
end
def
default_project_member_hash
{
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
.
id
}
end
...
...
lib/gitlab/import_export/project_tree_restorer.rb
View file @
2e1decd0
...
...
@@ -94,8 +94,10 @@ module Gitlab
end
def
relation_from_factory
(
relation
,
relation_hash
)
Gitlab
::
ImportExport
::
RelationFactory
.
create
(
relation_sym:
relation
.
to_sym
,
relation_hash:
relation_hash
.
merge
(
'project_id'
=>
project
.
id
),
members_mapper:
members_mapper
)
Gitlab
::
ImportExport
::
RelationFactory
.
create
(
relation_sym:
relation
.
to_sym
,
relation_hash:
relation_hash
.
merge
(
'project_id'
=>
project
.
id
),
members_mapper:
members_mapper
,
user_admin:
@user
.
is_admin?
)
end
end
end
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
2e1decd0
...
...
@@ -6,11 +6,11 @@ module Gitlab
OVERRIDES
=
{
snippets: :project_snippets
,
ci_commits:
'Ci::Commit'
,
statuses:
'commit_status'
}.
freeze
USER_REFERENCES
=
%w(author_id assignee_id updated_by_id)
.
freeze
def
create
(
relation_sym
:,
relation_hash
:,
members_mapper
:)
def
create
(
relation_sym
:,
relation_hash
:,
members_mapper
:
,
user_admin
:
)
relation_sym
=
parse_relation_sym
(
relation_sym
)
klass
=
parse_relation
(
relation_hash
,
relation_sym
)
update_missing_author
(
relation_hash
,
members_mapper
)
if
relation_sym
==
:notes
update_missing_author
(
relation_hash
,
members_mapper
,
user_admin
)
if
relation_sym
==
:notes
update_user_references
(
relation_hash
,
members_mapper
.
map
)
update_project_references
(
relation_hash
,
klass
)
...
...
@@ -27,12 +27,19 @@ module Gitlab
end
end
def
update_missing_author
(
relation_hash
,
members_map
)
def
update_missing_author
(
relation_hash
,
members_map
,
user_admin
)
old_author_id
=
relation_hash
[
'author_id'
]
relation_hash
[
'author_id'
]
=
members_map
.
map
[
old_author_id
]
# Users with admin access have access to mapping of users
if
user_admin
relation_hash
[
'author_id'
]
=
members_map
.
default_project_member
else
relation_hash
[
'author_id'
]
=
members_map
.
map
[
old_author_id
]
end
author
=
relation_hash
.
delete
(
'author'
)
return
unless
members_map
.
note_member_list
.
include?
(
old_author_id
)
return
unless
user_admin
&&
members_map
.
note_member_list
.
include?
(
old_author_id
)
relation_hash
[
'note'
]
=
(
'*Blank note*'
)
if
relation_hash
[
'note'
].
blank?
relation_hash
[
'note'
]
+=
(
missing_author_note
(
relation_hash
[
'updated_at'
],
author
[
'name'
]))
...
...
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