-
-
Save nirvdrum/214371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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