BigW Consortium Gitlab

repository_import_worker.rb 745 Bytes
Newer Older
1 2 3
class RepositoryImportWorker
  include Sidekiq::Worker
  include Gitlab::ShellAdapter
4
  include DedicatedSidekiqQueue
5

6
  attr_accessor :project, :current_user
7

8 9 10
  def perform(project_id)
    @project = Project.find(project_id)
    @current_user = @project.creator
11

12 13 14 15
    Gitlab::Metrics.add_event(:import_repository,
                              import_url: @project.import_url,
                              path: @project.path_with_namespace)

16 17
    project.update_column(:import_error, nil)

18
    result = Projects::ImportService.new(project, current_user).execute
19

20
    if result[:status] == :error
21
      project.mark_import_as_failed(result[:message])
22 23 24
      return
    end

25
    project.repository.after_import
26
    project.import_finish
27
  end
28
end