diff options
author | James Lopez <james@jameslopez.es> | 2016-05-18 17:55:26 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-05-18 17:55:26 +0200 |
commit | be0c266c7789e1e292865effd0b31e5dbb83f1e8 (patch) | |
tree | 8bf79da5fc546be66af56c24b85877820e2b96c4 | |
parent | 797504a8d91c06dc197cbadb27b892e8d54f9a66 (diff) | |
parent | 0de533ed08eb3e918f30c72a46635c256881d8c0 (diff) | |
download | gitlab-ce-be0c266c7789e1e292865effd0b31e5dbb83f1e8.tar.gz |
Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
-rw-r--r-- | lib/gitlab/import_export/attributes_finder.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 6 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export_reader.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/import_export/version_restorer.rb | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/project_tree_saver_spec.rb | 9 |
5 files changed, 22 insertions, 7 deletions
diff --git a/lib/gitlab/import_export/attributes_finder.rb b/lib/gitlab/import_export/attributes_finder.rb index 3439ef1006e..d230de781d5 100644 --- a/lib/gitlab/import_export/attributes_finder.rb +++ b/lib/gitlab/import_export/attributes_finder.rb @@ -2,9 +2,10 @@ module Gitlab module ImportExport class AttributesFinder - def initialize(included_attributes:, excluded_attributes:) + def initialize(included_attributes:, excluded_attributes:, methods:) @included_attributes = included_attributes || {} @excluded_attributes = excluded_attributes || {} + @methods = methods || {} end def find(model_object) @@ -27,10 +28,15 @@ module Gitlab @excluded_attributes[key].nil? ? {} : { except: @excluded_attributes[key] } end + def find_method(value) + key = key_from_hash(value) + @methods[key].nil? ? {} : { methods: @methods[key] } + end + private def find_attributes_only(value) - find_included(value).merge(find_excluded(value)) + find_included(value).merge(find_excluded(value)).merge(find_method(value)) end def key_from_hash(value) diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 947f3030f46..eef4d92beee 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -45,4 +45,8 @@ included_attributes: # Do not include the following attributes for the models specified. excluded_attributes: snippets: - - :expired_at
\ No newline at end of file + - :expired_at + +methods: + statuses: + - :type
\ No newline at end of file diff --git a/lib/gitlab/import_export/import_export_reader.rb b/lib/gitlab/import_export/import_export_reader.rb index 48a45be65e4..d42005b2bfd 100644 --- a/lib/gitlab/import_export/import_export_reader.rb +++ b/lib/gitlab/import_export/import_export_reader.rb @@ -9,7 +9,8 @@ module Gitlab config_hash = YAML.load_file(config).deep_symbolize_keys @tree = config_hash[:project_tree] @attributes_parser = Gitlab::ImportExport::AttributesFinder.new(included_attributes: config_hash[:included_attributes], - excluded_attributes: config_hash[:excluded_attributes]) + excluded_attributes: config_hash[:excluded_attributes], + methods: config_hash[:methods]) end def project_tree diff --git a/lib/gitlab/import_export/version_restorer.rb b/lib/gitlab/import_export/version_restorer.rb index 2c83bf08997..892352f5adf 100644 --- a/lib/gitlab/import_export/version_restorer.rb +++ b/lib/gitlab/import_export/version_restorer.rb @@ -34,4 +34,3 @@ module Gitlab end end end - diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb index b9cf88d3f77..1c55d0e33c1 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -84,10 +84,15 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do it 'has author on merge requests comments' do expect(saved_project_json['merge_requests'].first['notes'].first['author']).not_to be_empty end + it 'has commit statuses' do expect(saved_project_json['ci_commits'].first['statuses']).not_to be_empty end + it 'has CI builds' do + expect(saved_project_json['ci_commits'].first['statuses'].first['type']).to eq('Ci::Build') + end + it 'has ci commits' do expect(saved_project_json['ci_commits']).not_to be_empty end @@ -99,7 +104,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do merge_request = create(:merge_request) label = create(:label) snippet = create(:project_snippet) - commit_status = create(:commit_status) release = create(:release) project = create(:project, @@ -111,7 +115,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do releases: [release] ) - create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch, statuses: [commit_status]) + ci_commit = create(:ci_commit, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch) + create(:ci_build, commit: ci_commit) create(:milestone, project: project) create(:note, noteable: issue) create(:note, noteable: merge_request) |