Commit 54e6c004 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Added three rake tasks for repository maintainance

Tasks added:
gitlab:git:repack
gitlab:git:gc
gitlab:git:prune
parent a2f0a365
......@@ -62,6 +62,7 @@ v 8.0.4
- Fix "Assign All" button on Runner admin page
- Fix search in Files
- Add full project namespace to payload of system webhooks (Ricardo Band)
- Add rake tasks for git repository maintainance (Zeger-Jan van de Weg)
v 8.0.3
- Fix URL shown in Slack notifications
......
namespace :gitlab do
namespace :git do
desc "GitLab | Git | Repack"
task repack: :environment do
failures = perform_git_cmd('git repack -a --quiet', 'Git repack')
if failures.empty?
puts "Done".green
else
output_failures(failures)
end
end
desc "GitLab | Git | Run gits garbage collection on all repo's"
task gc: :environment do
failures = perform_git_cmd('git gc --auto --quiet', "Garbage Collection")
if failures.empty?
puts "Done".green
else
output_failures(failures)
end
end
desc "GitLab | Git | Git prune all repo's"
task prune: :environment do
failures = perform_git_cmd('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.each do |r|
puts "Performing #{message} at #{r}"
failures << r unless system(*%w(#{cmd}), chdir: r)
end
failures
end
def output_failures(failures)
puts "The following repositories reported errors:".red
failures.each { |f| puts "- #{f}" }
end
end
end
......@@ -128,4 +128,8 @@ namespace :gitlab do
false
end
end
def all_repos
Dir.glob(File.join(Gitlab.config.gitlab_shell.repos_path, '**/*\.git'))
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