2020-01-01 13:55:28 +05:30
|
|
|
require './spec/support/sidekiq_middleware'
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
Gitlab::Seeder.quiet do
|
2019-12-26 22:10:19 +05:30
|
|
|
User.not_mass_generated.sample(10).each do |user|
|
|
|
|
source_project = Project.not_mass_generated.public_only.sample
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
##
|
2019-12-04 20:38:33 +05:30
|
|
|
# 03_project.rb might not have created a public project because
|
2019-02-15 15:39:39 +05:30
|
|
|
# we use randomized approach (e.g. `Array#sample`).
|
|
|
|
return unless source_project
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
Sidekiq::Worker.skipping_transaction_check do
|
|
|
|
fork_project = Projects::ForkService.new(
|
|
|
|
source_project,
|
|
|
|
user,
|
|
|
|
namespace: user.namespace,
|
|
|
|
skip_disk_validation: true
|
|
|
|
).execute
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
# Seed-Fu runs this entire fixture in a transaction, so the `after_commit`
|
|
|
|
# hook won't run until after the fixture is loaded. That is too late
|
|
|
|
# since the Sidekiq::Testing block has already exited. Force clearing
|
|
|
|
# the `after_commit` queue to ensure the job is run now.
|
|
|
|
fork_project.send(:_run_after_commit_queue)
|
|
|
|
fork_project.import_state.send(:_run_after_commit_queue)
|
|
|
|
|
|
|
|
# Expire repository cache after import to ensure
|
|
|
|
# valid_repo? call below returns a correct answer
|
|
|
|
fork_project.repository.expire_all_method_caches
|
|
|
|
|
|
|
|
if fork_project.valid? && fork_project.valid_repo?
|
|
|
|
print '.'
|
|
|
|
else
|
|
|
|
print 'F'
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|