Commit 8db063b5 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg Committed by Zeger-Jan van de Weg

Scalable way of requesting all repos

parent 54e6c004
......@@ -3,7 +3,7 @@ namespace :gitlab do
desc "GitLab | Git | Repack"
task repack: :environment do
failures = perform_git_cmd('git repack -a --quiet', 'Git repack')
failures = perform_git_cmd(%W(git repack -a --quiet), "Repacking repo")
if failures.empty?
puts "Done".green
else
......@@ -11,9 +11,9 @@ namespace :gitlab do
end
end
desc "GitLab | Git | Run gits garbage collection on all repo's"
desc "GitLab | Git | Run garbage collection on all repos"
task gc: :environment do
failures = perform_git_cmd('git gc --auto --quiet', "Garbage Collection")
failures = perform_git_cmd(%W(git gc --auto --quiet), "Garbage Collecting")
if failures.empty?
puts "Done".green
else
......@@ -21,9 +21,9 @@ namespace :gitlab do
end
end
desc "GitLab | Git | Git prune all repo's"
desc "GitLab | Git | Prune all repos"
task prune: :environment do
failures = perform_git_cmd('git prune', 'Git Prune')
failures = perform_git_cmd(%W(git prune), "Git Prune")
if failures.empty?
puts "Done".green
else
......@@ -35,9 +35,12 @@ namespace :gitlab do
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)
all_repos do |repo|
if system(*cmd, chdir: repo)
puts "Performed #{message} at #{repo}"
else
failures << repo
end
end
failures
......
......@@ -130,6 +130,10 @@ namespace :gitlab do
end
def all_repos
Dir.glob(File.join(Gitlab.config.gitlab_shell.repos_path, '**/*\.git'))
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
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