2019-04-23 10:27:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module PhabricatorImport
|
|
|
|
class Importer
|
|
|
|
def self.async?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.imports_repository?
|
|
|
|
# This does not really import a repository, but we want to skip all
|
|
|
|
# repository related tasks in the `Projects::ImportService`
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(project)
|
|
|
|
@project = project
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2020-04-03 05:09:31 -04:00
|
|
|
Gitlab::Import::SetAsyncJid.set_jid(project.import_state)
|
2019-04-23 10:27:01 -04:00
|
|
|
schedule_first_tasks_page
|
|
|
|
|
|
|
|
true
|
2021-04-26 08:09:44 -04:00
|
|
|
rescue StandardError => e
|
2019-04-23 10:27:01 -04:00
|
|
|
fail_import(e.message)
|
|
|
|
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :project
|
|
|
|
|
|
|
|
def schedule_first_tasks_page
|
|
|
|
ImportTasksWorker.schedule(project.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def fail_import(message)
|
|
|
|
project.import_state.mark_as_failed(message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|