diff options
| author | Robert Speicher <robert@gitlab.com> | 2016-07-11 18:35:08 +0000 |
|---|---|---|
| committer | Robert Speicher <robert@gitlab.com> | 2016-07-11 18:35:08 +0000 |
| commit | 734e44ee79590be6d9f01ca3e815304221a5c88d (patch) | |
| tree | ee70a85d02d026316156ff31ae48f632d93abe6b /lib | |
| parent | 72b055d0d2dbebfffca1ff4cf55dda00a7eb362b (diff) | |
| parent | 95fe316f5d5cad06ed3457dd6c6f8263dfabd058 (diff) | |
| download | gitlab-ce-734e44ee79590be6d9f01ca3e815304221a5c88d.tar.gz | |
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
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 0ac6ff01e3b..025ecc12f9f 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -69,10 +69,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 |
