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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
1eb802cd
Commit
1eb802cd
authored
May 13, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed leaving comments on notes about missing authors
parent
a8682582
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
13 deletions
+20
-13
lib/gitlab/import_export/import_service.rb
lib/gitlab/import_export/import_service.rb
+6
-1
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+7
-6
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+1
-1
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+5
-4
spec/lib/gitlab/import_export/members_mapper_spec.rb
spec/lib/gitlab/import_export/members_mapper_spec.rb
+1
-1
No files found.
lib/gitlab/import_export/import_service.rb
View file @
1eb802cd
...
@@ -16,7 +16,12 @@ module Gitlab
...
@@ -16,7 +16,12 @@ module Gitlab
def
execute
def
execute
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
shared:
@shared
)
shared:
@shared
)
project_tree
.
project
if
[
restore_project_tree
,
restore_repo
,
restore_wiki_repo
].
all?
if
[
restore_project_tree
,
restore_repo
,
restore_wiki_repo
].
all?
project_tree
.
project
else
project_tree
.
project
.
destroy
if
project_tree
.
project
nil
end
end
end
private
private
...
...
lib/gitlab/import_export/members_mapper.rb
View file @
1eb802cd
...
@@ -4,10 +4,10 @@ module Gitlab
...
@@ -4,10 +4,10 @@ module Gitlab
attr_reader
:map
,
:note_member_list
attr_reader
:map
,
:note_member_list
def
initialize
(
exported_members
:,
user
:,
project
_id
:)
def
initialize
(
exported_members
:,
user
:,
project
:)
@exported_members
=
exported_members
@exported_members
=
exported_members
@user
=
user
@user
=
user
@project
_id
=
project_id
@project
=
project
@note_member_list
=
[]
@note_member_list
=
[]
@project_member_map
=
Hash
.
new
do
|
_
,
key
|
@project_member_map
=
Hash
.
new
do
|
_
,
key
|
...
@@ -36,20 +36,21 @@ module Gitlab
...
@@ -36,20 +36,21 @@ module Gitlab
end
end
def
member_hash
(
member
)
def
member_hash
(
member
)
member
.
except
(
'id'
).
merge
(
source_id:
@project
_
id
)
member
.
except
(
'id'
).
merge
(
source_id:
@project
.
id
)
end
end
#TODO: If default, then we need to leave a comment 'Comment by <original username>' on comments
def
default_project_member
def
default_project_member
@default_project_member
||=
@default_project_member
||=
begin
begin
return
@project
.
project_members
.
first
.
user
.
id
unless
@project
.
project_members
.
empty?
default_member
=
ProjectMember
.
new
(
default_project_member_hash
)
default_member
=
ProjectMember
.
new
(
default_project_member_hash
)
default_member
.
user
.
id
if
default_member
.
save
default_member
.
save!
default_member
.
user
.
id
end
end
end
end
def
default_project_member_hash
def
default_project_member_hash
{
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
_
id
}
{
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
.
id
}
end
end
def
find_project_user_query
(
member
)
def
find_project_user_query
(
member
)
...
...
lib/gitlab/import_export/project_tree_restorer.rb
View file @
1eb802cd
...
@@ -29,7 +29,7 @@ module Gitlab
...
@@ -29,7 +29,7 @@ module Gitlab
def
members_mapper
def
members_mapper
@members_mapper
||=
Gitlab
::
ImportExport
::
MembersMapper
.
new
(
exported_members:
@project_members
,
@members_mapper
||=
Gitlab
::
ImportExport
::
MembersMapper
.
new
(
exported_members:
@project_members
,
user:
@user
,
user:
@user
,
project
_id:
project
.
id
)
project
:
project
)
end
end
def
create_relations
(
relation_list
=
default_relation_list
,
tree_hash
=
@tree_hash
)
def
create_relations
(
relation_list
=
default_relation_list
,
tree_hash
=
@tree_hash
)
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
1eb802cd
...
@@ -30,16 +30,17 @@ module Gitlab
...
@@ -30,16 +30,17 @@ module Gitlab
def
update_missing_author
(
relation_hash
,
members_map
)
def
update_missing_author
(
relation_hash
,
members_map
)
old_author_id
=
relation_hash
[
'author_id'
]
old_author_id
=
relation_hash
[
'author_id'
]
relation_hash
[
'author_id'
]
=
members_map
.
map
[
old_author_id
]
relation_hash
[
'author_id'
]
=
members_map
.
map
[
old_author_id
]
author
=
relation_hash
.
delete
(
'author'
)
return
unless
members_map
.
note_member_list
.
include?
(
old_author_id
)
return
unless
members_map
.
note_member_list
.
include?
(
old_author_id
)
relation_hash
[
'note'
]
=
(
'*Blank note*'
)
if
relation_hash
[
'note'
].
blank?
relation_hash
[
'note'
]
=
(
'*Blank note*'
)
if
relation_hash
[
'note'
].
blank?
relation_hash
[
'note'
]
+=
(
missing_author_note
(
relation_hash
[
'updated_at'
],
relation_hash
[
'note'
]
+=
(
missing_author_note
(
relation_hash
[
'updated_at'
],
author
[
'name'
]))
relation_hash
[
'author'
][
'name'
]))
relation_hash
.
delete
(
'author'
)
end
end
def
missing_author_note
(
updated_at
,
author_name
)
def
missing_author_note
(
updated_at
,
author_name
)
"
\n\n
*By
#{
author_name
}
on
#{
updated_at
}
(imported from GitLab project)*"
timestamp
=
updated_at
.
split
(
'.'
).
first
"
\n\n
*By
#{
author_name
}
on
#{
timestamp
}
(imported from GitLab project)*"
end
end
def
update_project_references
(
relation_hash
,
klass
)
def
update_project_references
(
relation_hash
,
klass
)
...
...
spec/lib/gitlab/import_export/members_mapper_spec.rb
View file @
1eb802cd
...
@@ -32,7 +32,7 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
...
@@ -32,7 +32,7 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
let
(
:members_mapper
)
do
let
(
:members_mapper
)
do
described_class
.
new
(
described_class
.
new
(
exported_members:
exported_members
,
user:
user
,
project
_id:
project
.
id
)
exported_members:
exported_members
,
user:
user
,
project
:
project
)
end
end
it
'maps a project member'
do
it
'maps a project member'
do
...
...
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