Skip to content

Instantly share code, notes, and snippets.

@vito-lbs
Created July 28, 2014 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vito-lbs/87362a47fc369973379b to your computer and use it in GitHub Desktop.
Save vito-lbs/87362a47fc369973379b to your computer and use it in GitHub Desktop.
#!/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