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)
|
2015-02-18 16:00:26 +00:00
|
|
|
|
|
|
|
import_result = gitlab_shell.send(:import_repository,
|
2013-08-12 15:21:47 +00:00
|
|
|
project.path_with_namespace,
|
|
|
|
project.import_url)
|
2015-02-18 16:00:26 +00:00
|
|
|
return project.import_fail unless import_result
|
2013-08-12 15:21:47 +00:00
|
|
|
|
2015-02-18 16:00:26 +00:00
|
|
|
data_import_result = if project.import_type == 'github'
|
|
|
|
Gitlab::GithubImport::Importer.new(project).execute
|
|
|
|
elsif project.import_type == 'gitlab'
|
|
|
|
Gitlab::GitlabImport::Importer.new(project).execute
|
|
|
|
elsif project.import_type == 'bitbucket'
|
|
|
|
Gitlab::BitbucketImport::Importer.new(project).execute
|
2015-04-03 13:29:27 +00:00
|
|
|
elsif project.import_type == 'google_code'
|
|
|
|
Gitlab::GoogleCodeImport::Importer.new(project).execute
|
2015-02-18 16:00:26 +00:00
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
return project.import_fail unless data_import_result
|
2014-12-31 13:07:48 +00:00
|
|
|
|
2015-02-18 16:00:26 +00:00
|
|
|
project.import_finish
|
|
|
|
project.save
|
2015-08-11 08:28:42 +00:00
|
|
|
project.satellite.create unless project.satellite.exists?
|
2015-07-17 13:22:56 +00:00
|
|
|
ProjectCacheWorker.perform_async(project.id)
|
2015-02-18 16:00:26 +00:00
|
|
|
Gitlab::BitbucketImport::KeyDeleter.new(project).execute if project.import_type == 'bitbucket'
|
2013-08-12 15:21:47 +00:00
|
|
|
end
|
2014-09-25 22:07:40 +00:00
|
|
|
end
|