Commit 76efdea7 authored by James Lopez's avatar James Lopez

fixing MR issues with import

parent 1d8e02c4
......@@ -50,6 +50,8 @@ class MergeRequest < ActiveRecord::Base
delegate :commits, :diffs, :real_size, to: :merge_request_diff, prefix: nil
attr_accessor :importing
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
attr_accessor :allow_broken
......@@ -128,7 +130,7 @@ class MergeRequest < ActiveRecord::Base
validates :target_project, presence: true
validates :target_branch, presence: true
validates :merge_user, presence: true, if: :merge_when_build_succeeds?
validate :validate_branches
validate :validate_branches, unless: :importing
validate :validate_fork
scope :of_group, ->(group) { where("source_project_id in (:group_project_ids) OR target_project_id in (:group_project_ids)", group_project_ids: group.projects.select(:id).reorder(nil)) }
......
......@@ -44,7 +44,7 @@ module Projects
def create_relation(relation, relation_hash_list)
relation_hash_list.map do |relation_hash|
Projects::ImportExport::RelationFactory.create(
relation_sym: relation, relation_hash: relation_hash.merge(project_id: project.id), members_map: members_map)
relation_sym: relation, relation_hash: relation_hash.merge('project_id' => project.id), members_map: members_map)
end
end
end
......
......@@ -10,6 +10,12 @@ module Projects
relation_sym = parse_relation_sym(relation_sym)
klass = relation_class(relation_sym)
relation_hash.delete('id') #screw IDs for now
#TODO refactor this...
if relation_sym == :merge_requests
relation_hash['target_project_id'] = relation_hash.delete('project_id')
relation_hash['source_project_id'] = -1
relation_hash['importing'] = true
end
update_user_references(relation_hash, members_map)
klass.new(relation_hash)
end
......
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