2012-04-21 05:45:43 -04:00
|
|
|
namespace :gitlab do
|
2013-02-09 08:21:19 -05:00
|
|
|
namespace :satellites do
|
|
|
|
desc "GITLAB | Create satellite repos"
|
|
|
|
task create: :environment do
|
|
|
|
create_satellites
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_satellites
|
2012-12-23 15:14:30 -05: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 08:21:19 -05:00
|
|
|
return
|
2012-12-23 15:14:30 -05:00
|
|
|
end
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
Project.find_each(batch_size: 100) do |project|
|
|
|
|
print "#{project.name_with_namespace.yellow} ... "
|
2012-04-21 05:45:43 -04:00
|
|
|
|
2012-12-23 15:14:30 -05: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 13:38:44 -05:00
|
|
|
project.satellite.create
|
2012-12-23 15:14:30 -05:00
|
|
|
|
|
|
|
print "... "
|
|
|
|
if $?.success?
|
|
|
|
puts "created".green
|
|
|
|
else
|
|
|
|
puts "error".red
|
|
|
|
end
|
2012-04-22 08:19:09 -04:00
|
|
|
end
|
2012-04-21 05:45:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|