diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 09:41:27 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 12:58:13 +0000 |
commit | 4bd8a427d4e8127f1badc7365b35702472918956 (patch) | |
tree | d8e64bd046f35b64ad6f88bdd062e1e8f364c327 /lib | |
parent | d3f033d69cec33e8058ee9f029718882990175b0 (diff) | |
download | gitlab-ce-4bd8a427d4e8127f1badc7365b35702472918956.tar.gz |
Removes all the irrelevant import related code and columns
Clears the import related columns and code from the Project
model over to the ProjectImportState model
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/bitbucket_server_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer/repository_importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/github_import/parallel_importer.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/legacy_github_import/importer.rb | 3 | ||||
-rw-r--r-- | lib/tasks/import.rake | 4 |
8 files changed, 17 insertions, 13 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index cff05643f3b..4788b0e16a1 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -145,7 +145,9 @@ module API expose :import_status # TODO: Use `expose_nil` once we upgrade the grape-entity gem - expose :import_error, if: lambda { |status, _ops| status.import_error } + expose :import_error, if: lambda { |project, _ops| project.import_state&.last_error } do |project| + project.import_state.last_error + end end class BasicProjectDetails < ProjectIdentity @@ -248,7 +250,10 @@ module API expose :creator_id expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? } expose :import_status - expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } + + expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } do |project| + project.import_state&.last_error + end expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) } expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 45e550b3450..eaead41a720 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -35,7 +35,7 @@ module Gitlab def handle_errors return unless errors.any? - project.update_column(:import_error, { + project.import_state.update_column(:last_error, { message: 'The remote data could not be fully imported.', errors: errors }.to_json) diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index 15aa4739ee9..d4080536d81 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -56,7 +56,7 @@ module Gitlab def handle_errors return unless errors.any? - project.update_column(:import_error, { + project.import_state.update_column(:last_error, { message: 'The remote data could not be fully imported.', errors: errors }.to_json) diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb index 374dc9d3c00..bc3ea9e9226 100644 --- a/lib/gitlab/github_import/importer/repository_importer.rb +++ b/lib/gitlab/github_import/importer/repository_importer.rb @@ -80,7 +80,7 @@ module Gitlab end def fail_import(message) - project.mark_import_as_failed(message) + project.import_state.mark_as_failed(message) false end end diff --git a/lib/gitlab/github_import/parallel_importer.rb b/lib/gitlab/github_import/parallel_importer.rb index a77ac1e4fa6..9d81441d96e 100644 --- a/lib/gitlab/github_import/parallel_importer.rb +++ b/lib/gitlab/github_import/parallel_importer.rb @@ -41,8 +41,7 @@ module Gitlab Gitlab::SidekiqStatus .set(jid, StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION) - project.ensure_import_state - project.import_state&.update_column(:jid, jid) + project.import_state.update_column(:jid, jid) Stage::ImportRepositoryWorker .perform_async(project.id) diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index b40eac3de9a..8380e86c128 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -98,13 +98,11 @@ excluded_attributes: - :avatar - :import_type - :import_source - - :import_error - :mirror - :runners_token - :repository_storage - :repository_read_only - :lfs_enabled - - :import_jid - :created_at - :updated_at - :id @@ -116,6 +114,9 @@ excluded_attributes: - :remote_mirror_available_overridden - :description_html - :repository_languages + project_import_state: + - :last_error + - :jid prometheus_metrics: - :common - :identifier diff --git a/lib/gitlab/legacy_github_import/importer.rb b/lib/gitlab/legacy_github_import/importer.rb index 43695451b87..c526d31a591 100644 --- a/lib/gitlab/legacy_github_import/importer.rb +++ b/lib/gitlab/legacy_github_import/importer.rb @@ -80,8 +80,7 @@ module Gitlab def handle_errors return unless errors.any? - project.ensure_import_state - project.import_state&.update_column(:last_error, { + project.import_state.update_column(:last_error, { message: 'The remote data could not be fully imported.', errors: errors }.to_json) diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index a16d4c47273..f912f521dfb 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -42,7 +42,7 @@ class GithubImport end def import! - @project.force_import_start + @project.import_state.force_start import_success = false @@ -57,7 +57,7 @@ class GithubImport puts "Import finished. Timings: #{timings}".color(:green) else puts "Import was not successful. Errors were as follows:" - puts @project.import_error + puts @project.import_state.last_error end end |