2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Import large project archives
|
|
|
|
#
|
|
|
|
# This task:
|
|
|
|
# 1. Disables ObjectStorage for archive upload
|
|
|
|
# 2. Performs Sidekiq job synchronously
|
|
|
|
#
|
|
|
|
# @example
|
2020-03-13 15:44:24 +05:30
|
|
|
# bundle exec rake "gitlab:import_export:import[root, root, imported_project, /path/to/file.tar.gz, true]"
|
2020-01-01 13:55:28 +05:30
|
|
|
#
|
|
|
|
namespace :gitlab do
|
|
|
|
namespace :import_export do
|
2020-03-13 15:44:24 +05:30
|
|
|
desc 'GitLab | Import/Export | EXPERIMENTAL | Import large project archives'
|
|
|
|
task :import, [:username, :namespace_path, :project_path, :archive_path, :measurement_enabled] => :gitlab_environment do |_t, args|
|
2020-01-01 13:55:28 +05:30
|
|
|
# Load it here to avoid polluting Rake tasks with Sidekiq test warnings
|
|
|
|
require 'sidekiq/testing'
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
logger = Logger.new($stdout)
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
begin
|
|
|
|
warn_user_is_not_gitlab
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
if ENV['IMPORT_DEBUG'].present?
|
|
|
|
ActiveRecord::Base.logger = logger
|
|
|
|
logger.level = Logger::DEBUG
|
|
|
|
else
|
|
|
|
logger.level = Logger::INFO
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
task = Gitlab::ImportExport::Project::ImportTask.new(
|
|
|
|
namespace_path: args.namespace_path,
|
|
|
|
project_path: args.project_path,
|
|
|
|
username: args.username,
|
|
|
|
file_path: args.archive_path,
|
|
|
|
measurement_enabled: Gitlab::Utils.to_boolean(args.measurement_enabled),
|
|
|
|
logger: logger
|
|
|
|
)
|
|
|
|
|
|
|
|
success = task.import
|
|
|
|
|
|
|
|
exit(success)
|
|
|
|
rescue StandardError => e
|
|
|
|
logger.error "Exception: #{e.message}"
|
|
|
|
logger.debug e.backtrace
|
|
|
|
exit 1
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|