diff options
author | Valery Sizov <valery@gitlab.com> | 2015-07-27 08:06:42 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-07-27 08:06:42 +0000 |
commit | 4a8076a35f04661235d5393d7a5379c8654ea503 (patch) | |
tree | cdff7d573397852070e3dac428e57d997fc1c2dc | |
parent | e1cdc26e48831aadd261f6b0bd6755c9b8b41c89 (diff) | |
parent | d3cae9278fe36e8c7731aa6e7aaaf33014c8df7d (diff) | |
download | gitlab-ce-4a8076a35f04661235d5393d7a5379c8654ea503.tar.gz |
Merge branch 'rake-update-commit-count' into 'master'
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.
![gitlab-rake-update-commit-count](https://gitlab.com/gitlab-org/gitlab-ce/uploads/4785009e0f3fc4c3199fe65dfb8e60e0/gitlab-rake-update-commit-count.png)
Refs !986, !989, #2040, #2089.
See merge request !1040
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/tasks/gitlab/update_commit_count.rake | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG index e198b48e86e..25c023479e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 7.14.0 (unreleased) - Fix URL used for refreshing notes if relative_url is present (Bartłomiej Święcki) - Fix Error 500 when browsing projects with no HEAD (Stan Hu) + - Add rake task 'gitlab:update_commit_count' (Daniel Gerhardt) - Fix full screen mode for snippet comments (Daniel Gerhardt) - Fix 404 error in files view after deleting the last file in a repository (Stan Hu) - Fix the "Reload with full diff" URL button (Stan Hu) 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 |