2017-02-27 10:28:53 -05:00
|
|
|
require './spec/support/sidekiq'
|
|
|
|
|
|
|
|
def create_group_with_parents(user, full_path)
|
|
|
|
parent_path = nil
|
|
|
|
group = nil
|
|
|
|
|
|
|
|
until full_path.blank?
|
|
|
|
path, _, full_path = full_path.partition('/')
|
|
|
|
|
|
|
|
if parent_path
|
|
|
|
parent = Group.find_by_full_path(parent_path)
|
|
|
|
|
|
|
|
parent_path += '/'
|
|
|
|
parent_path += path
|
|
|
|
|
|
|
|
group = Groups::CreateService.new(user, path: path, parent_id: parent.id).execute
|
|
|
|
else
|
|
|
|
parent_path = path
|
|
|
|
|
|
|
|
group = Group.find_by_full_path(parent_path) ||
|
|
|
|
Groups::CreateService.new(user, path: path).execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
group
|
|
|
|
end
|
|
|
|
|
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
Gitlab::Seeder.quiet do
|
2017-04-10 16:18:58 -04:00
|
|
|
flag = 'SEED_NESTED_GROUPS'
|
2017-02-27 10:28:53 -05:00
|
|
|
|
2017-04-10 16:18:58 -04:00
|
|
|
if ENV[flag]
|
|
|
|
project_urls = [
|
|
|
|
'https://android.googlesource.com/platform/hardware/broadcom/libbt.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/broadcom/wlan.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/broadcom.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/freescale.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/imagination.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/intel.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git',
|
|
|
|
'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git'
|
|
|
|
]
|
2017-02-27 10:28:53 -05:00
|
|
|
|
2017-04-10 16:18:58 -04:00
|
|
|
user = User.admins.first
|
2017-02-27 10:28:53 -05:00
|
|
|
|
2017-04-10 16:18:58 -04:00
|
|
|
project_urls.each_with_index do |url, i|
|
|
|
|
full_path = url.sub('https://android.googlesource.com/', '')
|
|
|
|
full_path = full_path.sub(/\.git\z/, '')
|
|
|
|
full_path, _, project_path = full_path.rpartition('/')
|
|
|
|
group = Group.find_by_full_path(full_path) || create_group_with_parents(user, full_path)
|
2017-02-27 10:28:53 -05:00
|
|
|
|
2017-04-10 16:18:58 -04:00
|
|
|
params = {
|
|
|
|
import_url: url,
|
|
|
|
namespace_id: group.id,
|
|
|
|
path: project_path,
|
|
|
|
name: project_path,
|
|
|
|
description: FFaker::Lorem.sentence,
|
|
|
|
visibility_level: Gitlab::VisibilityLevel.values.sample
|
|
|
|
}
|
2017-02-27 10:28:53 -05:00
|
|
|
|
2017-04-10 16:18:58 -04:00
|
|
|
project = Projects::CreateService.new(user, params).execute
|
|
|
|
project.send(:_run_after_commit_queue)
|
|
|
|
|
|
|
|
if project.valid?
|
|
|
|
print '.'
|
|
|
|
else
|
|
|
|
print 'F'
|
|
|
|
end
|
2017-02-27 10:28:53 -05:00
|
|
|
end
|
2017-04-10 16:18:58 -04:00
|
|
|
else
|
|
|
|
puts "Skipped. Use the `#{flag}` environment variable to enable."
|
2017-02-27 10:28:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|