#!/usr/bin/env ruby
#!DESCRIBE: Migrate repos to gitolite

iam = "me"
from = "git@github.com:Me/"
to = "git@gitolite:"
repos = %w( ... )

File.open("repos.conf", ?w) do |f|
  repos.each do |r|
    f.puts "repo #{r}"
    f.puts "  RW+ = #{iam}"
  end
end

File.open("repos.script", ?w) do |f|
  f.puts "#!/bin/bash"
  repos.each do |r|
    f.puts "git clone --bare #{from}#{r} __repo_#{r}"
    f.puts "cd __repo_#{r}"
    f.puts "git push --all #{to}#{r}"
    f.puts "git push --tags #{to}#{r}"
    f.puts "cd .."
    f.puts "rm -rf __repo_#{r}"
    f.puts
  end
end

File.chmod(0744, "repos.script")

puts "Done generating; now push the contents of repos.conf to your gitolite config, then run the repos.script script."