2013-08-12 15:21:47 +00:00
|
|
|
class RepositoryImportWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
include Gitlab::ShellAdapter
|
|
|
|
|
|
|
|
sidekiq_options queue: :gitlab_shell
|
|
|
|
|
|
|
|
def perform(project_id)
|
|
|
|
project = Project.find(project_id)
|
|
|
|
result = gitlab_shell.send(:import_repository,
|
|
|
|
project.path_with_namespace,
|
|
|
|
project.import_url)
|
|
|
|
|
2015-02-05 18:31:36 +00:00
|
|
|
result_of_data_import = if project.import_type == 'github'
|
|
|
|
Gitlab::GithubImport::Importer.new(project).execute
|
|
|
|
elsif project.import_type == 'gitlab'
|
|
|
|
Gitlab::GitlabImport::Importer.new(project).execute
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
2014-12-31 13:07:48 +00:00
|
|
|
|
|
|
|
if result && result_of_data_import
|
2014-03-12 15:15:03 +00:00
|
|
|
project.import_finish
|
2013-08-12 15:21:47 +00:00
|
|
|
project.save
|
|
|
|
project.satellite.create unless project.satellite.exists?
|
2014-06-11 19:32:00 +00:00
|
|
|
project.update_repository_size
|
2013-08-12 15:21:47 +00:00
|
|
|
else
|
2014-03-12 15:15:03 +00:00
|
|
|
project.import_fail
|
2013-08-12 15:21:47 +00:00
|
|
|
end
|
|
|
|
end
|
2014-09-25 22:07:40 +00:00
|
|
|
end
|