enable_automerge.rake 858 Bytes
Newer Older
1
namespace :gitlab do
2
  namespace :satellites do
3
    desc "GitLab | Create satellite repos"
4 5 6 7 8 9
    task create: :environment do
      create_satellites
    end
  end

  def create_satellites
10 11 12 13 14
    warn_user_is_not_gitlab

    print "Creating satellites for ..."
    unless Project.count > 0
      puts "skipping, because you have no projects".magenta
15
      return
16 17 18 19 20
    end
    puts ""

    Project.find_each(batch_size: 100) do |project|
      print "#{project.name_with_namespace.yellow} ... "
21

22 23 24 25 26 27 28 29
      unless project.repo_exists?
        puts "skipping, because the repo is empty".magenta
        next
      end

      if project.satellite.exists?
        puts "exists already".green
      else
30 31
        print "\n... "
        if project.satellite.create
32 33 34 35
          puts "created".green
        else
          puts "error".red
        end
36
      end
37 38 39
    end
  end
end