BigW Consortium Gitlab

update_commit_count.rake 641 Bytes
Newer Older
1 2 3 4 5 6 7 8
namespace :gitlab do
  desc "GitLab | Update commit count for projects"
  task update_commit_count: :environment do
    projects = Project.where(commit_count: 0)
    puts "#{projects.size} projects need to be updated. This might take a while."
    ask_to_continue unless ENV['force'] == 'yes'

    projects.find_each(batch_size: 100) do |project|
9
      print "#{project.name_with_namespace.color(:yellow)} ... "
10 11

      unless project.repo_exists?
12
        puts "skipping, because the repo is empty".color(:magenta)
13 14 15 16
        next
      end

      project.update_commit_count
17
      puts project.commit_count.to_s.color(:green)
18 19 20
    end
  end
end