Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created September 30, 2009 12:57
Show Gist options
  • Save Sutto/198072 to your computer and use it in GitHub Desktop.
Save Sutto/198072 to your computer and use it in GitHub Desktop.
# Comment if you dont want rubygems
require 'rubygems'
require 'gitauth'
require 'fileutils'
if ARGV.empty?
puts "Usage: ruby #{$0} path-to-base-dir"
exit!
end
GitAuth.prepare
base_path = File.expand_path(ARGV.first)
Dir[File.join(base_path, "*")].each do |original_repo|
path = File.basename(original_repo)
name = path.gsub(/\.git$/, '')
puts "Creating repo #{name} at #{path}"
repo = GitAuth::Repo.create(name, path)
if repo
path = repo.real_path
Dir.chdir(File.dirname(path)) do
FileUtils.rm_rf path
GitAuth.run "git clone --mirror '#{original_repo}' #{File.basename(path)}"
end
else
puts "Unable to create '#{name}' under #{path}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment