diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 4a4392959a7fbba5e531bfd71d53c1827809278e..d780467034eae711d380d950161787baed2d155c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -161,6 +161,10 @@ module Ci git_commit_message =~ /(\[ci skip\])/ if git_commit_message end + def notes + Note.for_commit_id(sha) + end + private def update_state @@ -181,9 +185,5 @@ module Ci self.yaml_errors = error update_state end - - def notes - Note.for_commit_id(valid_commit_sha) - end end end diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index ee8fc544b60a828ec2411a619d6636465ab09a60..3796fc8cd0281352bed3b2da9e4264995d9e9a48 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -16,10 +16,10 @@ project_tree: - notes: :author - :merge_request_diff - - ci_commits: - - :statuses + - pipelines: - notes: :author + - :statuses - :variables - :triggers - :deploy_keys diff --git a/lib/gitlab/import_export/import_export_reader.rb b/lib/gitlab/import_export/import_export_reader.rb index c7a44efadf5ed83c02b6634ce56ea7ec3ecdd3c9..29b9ef24fde582551c07e4665566d866d22b9708 100644 --- a/lib/gitlab/import_export/import_export_reader.rb +++ b/lib/gitlab/import_export/import_export_reader.rb @@ -3,9 +3,8 @@ module Gitlab class ImportExportReader def initialize(shared:) - config = ImportExport.config_file @shared = shared - config_hash = YAML.load_file(config).deep_symbolize_keys + config_hash = YAML.load_file(Gitlab::ImportExport.config_file).deep_symbolize_keys @tree = config_hash[:project_tree] @attributes_finder = Gitlab::ImportExport::AttributesFinder.new(included_attributes: config_hash[:included_attributes], excluded_attributes: config_hash[:excluded_attributes], diff --git a/spec/lib/gitlab/import_export/import_export_reader_spec.rb b/spec/lib/gitlab/import_export/import_export_reader_spec.rb index c4d03fecd5449e4b121a987abcd757a1de0667a8..19f9bdc8d3f31bb5096c5506253e723006afddb5 100644 --- a/spec/lib/gitlab/import_export/import_export_reader_spec.rb +++ b/spec/lib/gitlab/import_export/import_export_reader_spec.rb @@ -16,7 +16,11 @@ describe Gitlab::ImportExport::ImportExportReader, lib: true do } end + before do + allow_any_instance_of(Gitlab::ImportExport).to receive(:config_file).and_return(test_config) + end + it 'generates hash from project tree config' do - expect(described_class.new(config: test_config, shared: shared).project_tree).to match(project_tree_hash) + expect(described_class.new(shared: shared).project_tree).to match(project_tree_hash) 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 c8505aa6be53dab4480ab2bc31708efb79825fd4..6e6adfd60eb0f90d535e9b400ac58cf692c4a212 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -89,20 +89,20 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true 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 + it 'has pipeline statuses' do + expect(saved_project_json['pipelines'].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') + it 'has pipeline builds' do + expect(saved_project_json['pipelines'].first['statuses'].first['type']).to eq('Ci::Build') end - it 'has ci commits' do - expect(saved_project_json['ci_commits']).not_to be_empty + it 'has pipeline commits' do + expect(saved_project_json['pipelines']).not_to be_empty end - it 'has ci commits notes' do - expect(saved_project_json['ci_commits'].first['notes']).not_to be_empty + it 'has ci pipeline notes' do + expect(saved_project_json['pipelines'].first['notes']).not_to be_empty end end end @@ -125,18 +125,21 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do commit_status = create(:commit_status, project: project) - ci_commit = create(:ci_commit, + ci_pipeline = create(:ci_pipeline, project: project, sha: merge_request.last_commit.id, ref: merge_request.source_branch, statuses: [commit_status]) - create(:ci_build, commit: ci_commit, project: project) + create(:ci_build, pipeline: ci_pipeline, project: project) create(:milestone, project: project) create(:note, noteable: issue, project: project) create(:note, noteable: merge_request, project: project) - create(:note, noteable: ci_commit, project: project) create(:note, noteable: snippet, project: project) + create(:note_on_commit, + author: user, + project: project, + commit_id: ci_pipeline.sha) project end