Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created December 27, 2009 21:49
Show Gist options
  • Select an option

  • Save wfarr/264410 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/264410 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'git'
require 'net/http'
require 'uri'
GIT_CONFIG = Git.global_config
USER = GIT_CONFIG['github.user']
KEY = GIT_CONFIG['github.token']
GH_URL = "http://github.com/api/v2/yaml/repos/show/#{USER}"
repos = YAML.load(Net::HTTP.post_form(URI.parse(GH_URL),
{'login' => USER,
'token' => KEY}).body)
Dir.chdir("#{ENV['HOME']}/Projects")
repos['repositories'].each do |repo|
name = repo[:name]
unless File.directory?(File.join(Dir.pwd, name))
if repo[:private]
repo_url = "git@github.com:#{USER}/#{name}.git"
else
repo_url = "git://github.com/#{USER}/#{name}.git"
end
end
puts "Cloning #{repo_url}"
Git.clone(repo_url, name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment