Class: Projects::ImportService

Inherits:
BaseService show all
Defined in:
app/services/projects/import_service.rb

Constant Summary collapse

Error =
Class.new(StandardError)
PermissionError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#async?Boolean

Returns true if this importer is supposed to perform its work in the background.

This method will only return `true` if async importing is explicitly supported by an importer class (`Gitlab::GithubImport::ParallelImporter` for example).

Returns:

  • (Boolean)

14
15
16
# File 'app/services/projects/import_service.rb', line 14

def async?
  has_importer? && !!importer_class.try(:async?)
end

#executeObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/services/projects/import_service.rb', line 18

def execute
  add_repository_to_project

  download_lfs_objects

  import_data

  after_execute_hook

  success
rescue Gitlab::UrlBlocker::BlockedUrlError => e
  Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)

  error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message })
rescue => e
  message = Projects::ImportErrorFilter.filter_message(e.message)

  Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)

  error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: message })
end