2015-07-24 10:09:19 -04:00
|
|
|
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|
|
2016-06-01 18:37:15 -04:00
|
|
|
print "#{project.name_with_namespace.color(:yellow)} ... "
|
2015-07-24 10:09:19 -04:00
|
|
|
|
|
|
|
unless project.repo_exists?
|
2016-06-01 18:37:15 -04:00
|
|
|
puts "skipping, because the repo is empty".color(:magenta)
|
2015-07-24 10:09:19 -04:00
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
project.update_commit_count
|
2016-06-01 18:37:15 -04:00
|
|
|
puts project.commit_count.to_s.color(:green)
|
2015-07-24 10:09:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|