diff options
author | Robert Speicher <robert@gitlab.com> | 2016-07-11 21:35:08 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-07-11 21:37:30 +0300 |
commit | ac9e49fdf04c349744648ea807a79f7a50f4b1c9 (patch) | |
tree | eb452572e29dfaaef37e10ed1817bac237e22e1d /lib | |
parent | 43d6c0beabe4b32e65d0f49f6e3213aeb5e3ff75 (diff) |
Merge branch 'fix/import-event-error' into 'master'
Fix problems with events under notes importing GitLab projects
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19588
See merge request !5154
(cherry picked from commit 734e44ee79590be6d9f01ca3e815304221a5c88d)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/project_tree_restorer.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index dd71b92c522..e2413b082b2 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -70,10 +70,19 @@ module Gitlab # Example: # +relation_key+ issues, loops through the list of *issues* and for each individual # issue, finds any subrelations such as notes, creates them and assign them back to the hash + # + # Recursively calls this method if the sub-relation is a hash containing more sub-relations def create_sub_relations(relation, tree_hash) relation_key = relation.keys.first.to_s + return if tree_hash[relation_key].blank? + tree_hash[relation_key].each do |relation_item| relation.values.flatten.each do |sub_relation| + # We just use author to get the user ID, do not attempt to create an instance. + next if sub_relation == :author + + create_sub_relations(sub_relation, relation_item) if sub_relation.is_a?(Hash) + relation_hash, sub_relation = assign_relation_hash(relation_item, sub_relation) relation_item[sub_relation.to_s] = create_relation(sub_relation, relation_hash) unless relation_hash.blank? end |