Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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