2015-12-23 02:04:40 +05:30
|
|
|
namespace :gitlab do
|
|
|
|
namespace :git do
|
|
|
|
desc "GitLab | Git | Repack"
|
|
|
|
task repack: :environment do
|
2017-08-17 22:00:37 +05:30
|
|
|
failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} repack -a --quiet), "Repacking repo")
|
2015-12-23 02:04:40 +05:30
|
|
|
if failures.empty?
|
2016-06-16 23:09:34 +05:30
|
|
|
puts "Done".color(:green)
|
2015-12-23 02:04:40 +05:30
|
|
|
else
|
|
|
|
output_failures(failures)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "GitLab | Git | Run garbage collection on all repos"
|
|
|
|
task gc: :environment do
|
2017-08-17 22:00:37 +05:30
|
|
|
failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} gc --auto --quiet), "Garbage Collecting")
|
2015-12-23 02:04:40 +05:30
|
|
|
if failures.empty?
|
2016-06-16 23:09:34 +05:30
|
|
|
puts "Done".color(:green)
|
2015-12-23 02:04:40 +05:30
|
|
|
else
|
|
|
|
output_failures(failures)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
desc "GitLab | Git | Prune all repos"
|
|
|
|
task prune: :environment do
|
2017-08-17 22:00:37 +05:30
|
|
|
failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} prune), "Git Prune")
|
2015-12-23 02:04:40 +05:30
|
|
|
if failures.empty?
|
2016-06-16 23:09:34 +05:30
|
|
|
puts "Done".color(:green)
|
2015-12-23 02:04:40 +05:30
|
|
|
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)
|
2016-06-16 23:09:34 +05:30
|
|
|
puts "The following repositories reported errors:".color(:red)
|
2015-12-23 02:04:40 +05:30
|
|
|
failures.each { |f| puts "- #{f}" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|