BigW Consortium Gitlab

Commit 5355589c by James Lopez

Merge branches 'feature/project-export-ui-experimental' and…

Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
parents c487e6d3 1eb802cd
......@@ -16,7 +16,12 @@ module Gitlab
def execute
Gitlab::ImportExport::Importer.import(archive_file: @archive_file,
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
private
......
......@@ -4,10 +4,10 @@ module Gitlab
attr_reader :map, :note_member_list
def initialize(exported_members:, user:, project_id:)
def initialize(exported_members:, user:, project:)
@exported_members = exported_members
@user = user
@project_id = project_id
@project = project
@note_member_list = []
@project_member_map = Hash.new do |_, key|
......@@ -36,20 +36,21 @@ module Gitlab
end
def member_hash(member)
member.except('id').merge(source_id: @project_id)
member.except('id').merge(source_id: @project.id)
end
#TODO: If default, then we need to leave a comment 'Comment by <original username>' on comments
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.user.id if default_member.save
default_member.save!
default_member.user.id
end
end
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
def find_project_user_query(member)
......
......@@ -29,7 +29,7 @@ module Gitlab
def members_mapper
@members_mapper ||= Gitlab::ImportExport::MembersMapper.new(exported_members: @project_members,
user: @user,
project_id: project.id)
project: project)
end
def create_relations(relation_list = default_relation_list, tree_hash = @tree_hash)
......
......@@ -30,16 +30,17 @@ module Gitlab
def update_missing_author(relation_hash, members_map)
old_author_id = relation_hash['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)
relation_hash['note'] = ('*Blank note*') if relation_hash['note'].blank?
relation_hash['note'] += (missing_author_note(relation_hash['updated_at'],
relation_hash['author']['name']))
relation_hash.delete('author')
relation_hash['note'] += (missing_author_note(relation_hash['updated_at'], author['name']))
end
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
def update_project_references(relation_hash, klass)
......
......@@ -32,7 +32,7 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
let(:members_mapper) do
described_class.new(
exported_members: exported_members, user: user, project_id: project.id)
exported_members: exported_members, user: user, project: project)
end
it 'maps a project member' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment