diff options
author | Daniel Gerhardt <code@dgerhardt.net> | 2015-07-24 16:09:19 +0200 |
---|---|---|
committer | Daniel Gerhardt <code@dgerhardt.net> | 2015-07-24 16:20:28 +0200 |
commit | d3cae9278fe36e8c7731aa6e7aaaf33014c8df7d (patch) | |
tree | 2cc81b6d5b101621a91b1385a07dbfe2fcd81183 /lib/tasks | |
parent | 70de5114fbedf7c6a4557b10649003f5ccba6804 (diff) | |
download | gitlab-ce-d3cae9278fe36e8c7731aa6e7aaaf33014c8df7d.tar.gz |
Add rake task 'gitlab:update_commit_count'
Starting with migration `20150717130904` commit count is stored in the
database. For existing projects it defaults to `0` and is updated to the
correct value when commits are pushed.
The newly introduced rake task updates the commit count for all projects
which have not been updated yet.
Refs !986, !989, #2040.
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/update_commit_count.rake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/update_commit_count.rake b/lib/tasks/gitlab/update_commit_count.rake new file mode 100644 index 00000000000..9b636f12d9f --- /dev/null +++ b/lib/tasks/gitlab/update_commit_count.rake @@ -0,0 +1,20 @@ +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| + print "#{project.name_with_namespace.yellow} ... " + + unless project.repo_exists? + puts "skipping, because the repo is empty".magenta + next + end + + project.update_commit_count + puts project.commit_count.to_s.green + end + end +end |