summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/relation_factory.rb
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-05-03 11:02:26 +0200
committerFrancisco Javier López <fjlopez@gitlab.com>2018-05-14 09:28:33 +0200
commit761d890a68c92c49136937dbceda9f40bd714801 (patch)
tree406fed54b0140b5445fc1d69c8dd2b864623dc84 /lib/gitlab/import_export/relation_factory.rb
parent7c3838ea3e5cd6c7141b668f8171dd7257435ac1 (diff)
downloadgitlab-ce-761d890a68c92c49136937dbceda9f40bd714801.tar.gz
Blacklisting attributes in the project import process
Diffstat (limited to 'lib/gitlab/import_export/relation_factory.rb')
-rw-r--r--lib/gitlab/import_export/relation_factory.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index e3e9f156fb4..301719406e4 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -36,13 +36,21 @@ module Gitlab
new(*args).create
end
- def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:)
+ def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:, excluded_keys: [])
@relation_name = OVERRIDES[relation_sym] || relation_sym
@relation_hash = relation_hash.except('noteable_id')
@members_mapper = members_mapper
@user = user
@project = project
@imported_object_retries = 0
+
+ # Remove excluded keys from relation_hash
+ # We don't do this in the parsed_relation_hash because of the 'transformed attributes'
+ # For example, MergeRequestDiffFiles exports its diff attribute as utf8_diff. Then,
+ # in the create method that attribute is renamed to diff. And because diff is an excluded key,
+ # if we clean the excluded keys in the parsed_relation_hash, it will be removed
+ # from the object attributes and the export will fail.
+ @relation_hash.except!(*excluded_keys)
end
# Creates an object from an actual model with name "relation_sym" with params from