Skip to content
Snippets Groups Projects
Commit da60baf2 authored by James Lopez's avatar James Lopez
Browse files

fixing more importing issues

parent 56fc5893
No related branches found
No related tags found
2 merge requests!3142Project import functionality,!3114Export project functionality
Pipeline #
Loading
Loading
@@ -37,7 +37,9 @@ class MergeRequestDiff < ActiveRecord::Base
serialize :st_commits
serialize :st_diffs
 
after_create :reload_content
after_create :reload_content, unless: :importing
attr_accessor :importing
 
def reload_content
reload_commits
Loading
Loading
Loading
Loading
@@ -71,9 +71,10 @@ module Projects
# TODO refactor this
relation_key = relation.keys.first
tree_hash[relation_key.to_s].each do |relation_item|
relation.values.each do |sub_relation|
relation.values.flatten.each do |sub_relation|
relation_hash = relation_item[sub_relation.to_s]
next if relation_hash.blank?
relation_hash.merge!('project_id' => project.id) if sub_relation == :merge_requests
sub_relation_object = Projects::ImportExport::RelationFactory.create(
relation_sym: sub_relation, relation_hash: relation_hash, members_map: members_map)
relation_item[sub_relation.to_s] = sub_relation_object
Loading
Loading
Loading
Loading
@@ -7,12 +7,14 @@ module Projects
USER_REFERENCES = %w(author_id assignee_id updated_by_id).freeze
 
def create(relation_sym:, relation_hash:, members_map:)
#TODO refactor this
relation_sym = parse_relation_sym(relation_sym)
klass = relation_class(relation_sym)
relation_hash.delete('id') #screw IDs for now
handle_merge_requests(relation_hash) if relation_sym == :merge_requests
update_user_references(relation_hash, members_map)
klass.new(relation_hash)
imported_object = klass.new(relation_hash)
imported_object.importing = true if imported_object.respond_to?(:importing)
end
 
private
Loading
Loading
@@ -20,7 +22,6 @@ module Projects
def handle_merge_requests(relation_hash)
relation_hash['target_project_id'] = relation_hash.delete('project_id')
relation_hash['source_project_id'] = -1
relation_hash['importing'] = true
end
 
#TODO nice to have, optimize this to only get called for specific models
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment