BigW Consortium Gitlab

Commit a80f0f66 by Jacob Vosmaer

Merge branch 'rake-tasks-git' into 'master'

Added 3 rake tasks for repository maintainance ## What does this MR do? This MR adds 3 rake tasks - gitlab:git:repack - `-a` - `--quiet` - gitlab:git:gc - `--auto` - `--quiet` - gitlab:git:prune - Needs git version > 1.8.4.1, Ubuntu repos @ 1.9.x ## Are there points in the code the reviewer needs to double check? AFAIK this MR abides by the Guidelines for shell commands. Also, the output given is not the diskspace saved etc, just if the commands were succesfull. (Parsing output etc did not seem like the way to go) Output might be verbose when a lot of repo's are in the system? ## Why was this MR needed? `git gc` and `git prune` can reduce storage space used. ## What are the relevant issue numbers / Feature requests? Closes #1529 ## Screenshots (if relevant) `rake -T` ![Screenshot_from_2015-09-22_14-57-59](https://gitlab.com/zj/gitlab-ce/uploads/4abfa00ce7afcc73f553d92581246731/Screenshot_from_2015-09-22_14-57-59.png) (git fsck now removed as IMHO it doesn't add any value.) See merge request !1388
parents 4cd259e9 3da32ef7
...@@ -5,6 +5,7 @@ v 8.3.0 (unreleased) ...@@ -5,6 +5,7 @@ v 8.3.0 (unreleased)
- Fix API setting of 'public' attribute to false will make a project private (Stan Hu) - Fix API setting of 'public' attribute to false will make a project private (Stan Hu)
- Handle and report SSL errors in Web hook test (Stan Hu) - Handle and report SSL errors in Web hook test (Stan Hu)
- Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera) - Fix: Assignee selector is empty when 'Unassigned' is selected (Jose Corcuera)
- Add rake tasks for git repository maintainance (Zeger-Jan van de Weg)
- Fix 500 error when update group member permission - Fix 500 error when update group member permission
- Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera) - Trim leading and trailing whitespace of milestone and issueable titles (Jose Corcuera)
- Recognize issue/MR/snippet/commit links as references - Recognize issue/MR/snippet/commit links as references
......
namespace :gitlab do
namespace :git do
desc "GitLab | Git | Repack"
task repack: :environment do
failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo")
if failures.empty?
puts "Done".green
else
output_failures(failures)
end
end
desc "GitLab | Git | Run garbage collection on all repos"
task gc: :environment do
failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting")
if failures.empty?
puts "Done".green
else
output_failures(failures)
end
end
desc "GitLab | Git | Prune all repos"
task prune: :environment do
failures = perform_git_cmd(%W(git prune), "Git Prune")
if failures.empty?
puts "Done".green
else
output_failures(failures)
end
end
def perform_git_cmd(cmd, message)
puts "Starting #{message} on all repositories"
failures = []
all_repos do |repo|
if system(*cmd, chdir: repo)
puts "Performed #{message} at #{repo}"
else
failures << repo
end
end
failures
end
def output_failures(failures)
puts "The following repositories reported errors:".red
failures.each { |f| puts "- #{f}" }
end
end
end
...@@ -118,4 +118,12 @@ namespace :gitlab do ...@@ -118,4 +118,12 @@ namespace :gitlab do
false false
end end
end end
def all_repos
IO.popen(%W(find #{Gitlab.config.gitlab_shell.repos_path} -mindepth 2 -maxdepth 2 -type d -name *.git)) do |find|
find.each_line do |path|
yield path.chomp
end
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment