Created
July 28, 2014 19:44
-
-
Save vito-lbs/87362a47fc369973379b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'pp' | |
host = "git@legitbs git server" | |
in_git = FileTest.exist?(File.join(Dir.pwd, '.git')) | |
if in_git | |
puts <<-EOS | |
Don't run this from inside a git working copy, run it from an empty | |
directory you want filled up with our repos. Thanks in advance. | |
EOS | |
exit -1 | |
end | |
repo_names = `ssh #{host} | grep "R W" | awk '{print $3}'`.lines.map(&:chomp) | |
no_clone, to_clone = repo_names.partition do |n| | |
candidate = File.join(Dir.pwd, n) | |
stat = File::Stat.new(candidate) rescue false | |
stat && stat.directory? | |
end | |
puts "Skipping:" | |
pp no_clone | |
puts | |
puts "Cloning:" | |
pp to_clone | |
to_clone.each do |c| | |
pid = Process.fork do | |
sh = "git clone #{host}:#{c}.git" | |
puts sh | |
Process.exec sh | |
end | |
Process.wait pid | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment