2012-04-21 11:45:43 +02:00
|
|
|
namespace :gitlab do
|
2013-02-09 14:21:19 +01:00
|
|
|
namespace :satellites do
|
|
|
|
desc "GITLAB | Create satellite repos"
|
|
|
|
task create: :environment do
|
|
|
|
create_satellites
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_satellites
|
2012-12-23 21:14:30 +01:00
|
|
|
warn_user_is_not_gitlab
|
|
|
|
|
|
|
|
print "Creating satellites for ..."
|
|
|
|
unless Project.count > 0
|
|
|
|
puts "skipping, because you have no projects".magenta
|
2013-02-09 14:21:19 +01:00
|
|
|
return
|
2012-12-23 21:14:30 +01:00
|
|
|
end
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
Project.find_each(batch_size: 100) do |project|
|
|
|
|
print "#{project.name_with_namespace.yellow} ... "
|
2012-04-21 11:45:43 +02:00
|
|
|
|
2012-12-23 21:14:30 +01:00
|
|
|
unless project.repo_exists?
|
|
|
|
puts "skipping, because the repo is empty".magenta
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
if project.satellite.exists?
|
|
|
|
puts "exists already".green
|
|
|
|
else
|
|
|
|
puts ""
|
2012-12-20 19:38:44 +01:00
|
|
|
project.satellite.create
|
2012-12-23 21:14:30 +01:00
|
|
|
|
|
|
|
print "... "
|
|
|
|
if $?.success?
|
|
|
|
puts "created".green
|
|
|
|
else
|
|
|
|
puts "error".red
|
|
|
|
end
|
2012-04-22 14:19:09 +02:00
|
|
|
end
|
2012-04-21 11:45:43 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|