Created
October 31, 2013 19:53
-
-
Save ryanfb/7255975 to your computer and use it in GitHub Desktop.
Clone all forks in a GitHub repository's network.
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
#!/usr/bin/env ruby | |
require 'json' | |
require 'open-uri' | |
require 'fileutils' | |
def clone_repo(repo) | |
puts repo['full_name'] | |
owner, path = repo['full_name'].split('/') | |
FileUtils.mkdir_p(owner) | |
unless File.directory?(repo['full_name']) | |
`git clone "#{repo['clone_url']}" "#{repo['full_name']}"` | |
end | |
end | |
github_api = "https://api.github.com/repos" | |
master = File.join(ARGV[0],ARGV[1]) | |
FileUtils.mkdir_p(master) | |
Dir.chdir(master) | |
clone_repo(JSON.parse(open("#{github_api}/#{ARGV[0]}/#{ARGV[1]}").read)) | |
forks = JSON.parse(open("#{github_api}/#{ARGV[0]}/#{ARGV[1]}/forks").read) | |
forks.each do |fork| | |
clone_repo(fork) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also https://github.com/endolith/clone_and_add_forks