summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-09-27 13:54:26 +0000
committerRuben Davila <rdavila84@gmail.com>2016-09-28 10:35:18 -0500
commit57837fd1ca96532e8e2ac0f3260dc3c028aebbb0 (patch)
tree02a45c7fb27fbd96494406d59f6147f0c24e80fc /lib
parent712bd173e841c34133ef5d130bfac6daf78aa46e (diff)
downloadgitlab-ce-57837fd1ca96532e8e2ac0f3260dc3c028aebbb0.tar.gz
Merge branch 'fix/import-new-models-error' into 'master'
Fix Import/Export milestone and 1to1 models issue Fix 1to1 relations on project failing to be importing and milestone ordering issue. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/22585 See merge request !6521 Conflicts: spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/import_export/import_export.yml6
-rw-r--r--lib/gitlab/import_export/project_tree_restorer.rb8
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index 88803d76623..003c7cc4b94 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -1,5 +1,8 @@
# Model relationships to be included in the project import/export
project_tree:
+ - :labels
+ - milestones:
+ - :events
- issues:
- :events
- notes:
@@ -39,9 +42,6 @@ project_tree:
- protected_branches:
- :merge_access_levels
- :push_access_levels
- - :labels
- - milestones:
- - :events
- :project_feature
# Only include the following attributes for the models specified.
diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb
index c7b3551b84c..35ff134ea19 100644
--- a/lib/gitlab/import_export/project_tree_restorer.rb
+++ b/lib/gitlab/import_export/project_tree_restorer.rb
@@ -61,11 +61,17 @@ module Gitlab
def restore_project
return @project unless @tree_hash
- project_params = @tree_hash.reject { |_key, value| value.is_a?(Array) }
@project.update(project_params)
@project
end
+ def project_params
+ @tree_hash.reject do |key, value|
+ # return params that are not 1 to many or 1 to 1 relations
+ value.is_a?(Array) || key == key.singularize
+ end
+ end
+
# Given a relation hash containing one or more models and its relationships,
# loops through each model and each object from a model type and
# and assigns its correspondent attributes hash from +tree_hash+