summaryrefslogtreecommitdiffstats
path: root/script/repo_housekeeping
blob: fd0b3038c4a9c780670593d572982694b871cdfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../config/environment'

$verbose = (ARGV[0] == "verbose")

repos_to_gc = Repository.all_due_for_gc
if $verbose
  puts "Garbage collecting #{repos_to_gc.length} repositories:"
  puts "=" * 72
end

repos_to_gc.each_with_index do |repo, idx|
  if $verbose
    start = Time.now
    print "#{idx+1}/#{repos_to_gc.length} GC'ing #{repo.url_path} (#{repo.id}) ..."
  end
  unless repo.gc!
    $stderr.puts "GC FAIL: Repository##{repo.id} (#{repo.url_path}"
  end
  print " Completed in #{Time.now - start}\n" if $verbose
end