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 ...@@ -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
......
...@@ -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)
......
...@@ -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)
......
...@@ -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)
......
...@@ -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
......
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