2014-09-02 18:07:02 +05:30
|
|
|
class RepositoryImportWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
include Gitlab::ShellAdapter
|
2016-11-03 12:29:30 +05:30
|
|
|
include DedicatedSidekiqQueue
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
attr_accessor :project, :current_user
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
def perform(project_id)
|
|
|
|
@project = Project.find(project_id)
|
|
|
|
@current_user = @project.creator
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
Gitlab::Metrics.add_event(:import_repository,
|
|
|
|
import_url: @project.import_url,
|
|
|
|
path: @project.path_with_namespace)
|
|
|
|
|
|
|
|
project.update_column(:import_error, nil)
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
result = Projects::ImportService.new(project, current_user).execute
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
if result[:status] == :error
|
2016-06-16 23:09:34 +05:30
|
|
|
project.mark_import_as_failed(result[:message])
|
2015-11-26 14:37:03 +05:30
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
project.repository.after_import
|
2015-04-26 12:48:37 +05:30
|
|
|
project.import_finish
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|