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 ...@@ -3,7 +3,7 @@ namespace :gitlab do
desc "GitLab | Git | Repack" desc "GitLab | Git | Repack"
task repack: :environment do 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? if failures.empty?
puts "Done".green puts "Done".green
else else
...@@ -11,9 +11,9 @@ namespace :gitlab do ...@@ -11,9 +11,9 @@ namespace :gitlab do
end end
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 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? if failures.empty?
puts "Done".green puts "Done".green
else else
...@@ -21,9 +21,9 @@ namespace :gitlab do ...@@ -21,9 +21,9 @@ namespace :gitlab do
end end
end end
desc "GitLab | Git | Git prune all repo's" desc "GitLab | Git | Prune all repos"
task prune: :environment do task prune: :environment do
failures = perform_git_cmd('git prune', 'Git Prune') failures = perform_git_cmd(%W(git prune), "Git Prune")
if failures.empty? if failures.empty?
puts "Done".green puts "Done".green
else else
...@@ -35,9 +35,12 @@ namespace :gitlab do ...@@ -35,9 +35,12 @@ namespace :gitlab do
puts "Starting #{message} on all repositories" puts "Starting #{message} on all repositories"
failures = [] failures = []
all_repos.each do |r| all_repos do |repo|
puts "Performing #{message} at #{r}" if system(*cmd, chdir: repo)
failures << r unless system(*%w(#{cmd}), chdir: r) puts "Performed #{message} at #{repo}"
else
failures << repo
end
end end
failures failures
......
...@@ -130,6 +130,10 @@ namespace :gitlab do ...@@ -130,6 +130,10 @@ namespace :gitlab do
end end
def all_repos 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
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