diff options
author | Rémy Coutable <remy@rymai.me> | 2017-05-03 10:12:34 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-05-03 10:12:34 +0000 |
commit | 40cc917a9c07263db062c03f62c8056ed40197bd (patch) | |
tree | 1a6eb510ae73492e00d6d3621a3138d869c9d8fe /lib | |
parent | d811004d023cee1ae5cbcb5792faca34b30336a3 (diff) | |
parent | 2174e37845f6865c20ba94da5520c8d9e874998f (diff) | |
download | gitlab-ce-40cc917a9c07263db062c03f62c8056ed40197bd.tar.gz |
Merge branch 'fix/import-export-missing-attributes' into 'master'
Include missing project attributes to Import/Export
Closes gitlab-ee#2251 and #26333
See merge request !10880
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 30 | ||||
-rw-r--r-- | lib/gitlab/import_export/project_tree_restorer.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/import_export/reader.rb | 5 |
3 files changed, 31 insertions, 8 deletions
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 899a6567768..b95cea371b9 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -41,7 +41,6 @@ project_tree: - :statuses - triggers: - :trigger_schedule - - :deploy_keys - :services - :hooks - protected_branches: @@ -53,10 +52,6 @@ project_tree: # Only include the following attributes for the models specified. included_attributes: - project: - - :description - - :visibility_level - - :archived user: - :id - :email @@ -66,6 +61,29 @@ included_attributes: # Do not include the following attributes for the models specified. excluded_attributes: + project: + - :name + - :path + - :namespace_id + - :creator_id + - :import_url + - :import_status + - :avatar + - :import_type + - :import_source + - :import_error + - :mirror + - :runners_token + - :repository_storage + - :repository_read_only + - :lfs_enabled + - :import_jid + - :created_at + - :updated_at + - :import_jid + - :import_jid + - :id + - :star_count snippets: - :expired_at merge_request_diff: @@ -94,3 +112,5 @@ methods: - :utf8_st_diffs merge_requests: - :diff_head_sha + project: + - :description_html
\ No newline at end of file diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index 2e349b5f9a9..84ab1977dfa 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -71,14 +71,14 @@ module Gitlab def restore_project return @project unless @tree_hash - @project.update(project_params) + @project.update_columns(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 + value.respond_to?(:each) && !Project.column_names.include?(key) end end diff --git a/lib/gitlab/import_export/reader.rb b/lib/gitlab/import_export/reader.rb index a1e7159fe42..eb7f5120592 100644 --- a/lib/gitlab/import_export/reader.rb +++ b/lib/gitlab/import_export/reader.rb @@ -15,7 +15,10 @@ module Gitlab # Outputs a hash in the format described here: http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html # for outputting a project in JSON format, including its relations and sub relations. def project_tree - @attributes_finder.find_included(:project).merge(include: build_hash(@tree)) + attributes = @attributes_finder.find(:project) + project_attributes = attributes.is_a?(Hash) ? attributes[:project] : {} + + project_attributes.merge(include: build_hash(@tree)) rescue => e @shared.error(e) false |