Last active
December 25, 2015 16:09
-
-
Save xnzac/7003545 to your computer and use it in GitHub Desktop.
Fetch all forks of github repository. Uses gems 'github_api' and 'hub'
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 | |
# Install gems: | |
# gem install github_api | |
# gem install hub | |
# | |
# Then run script in github repo | |
require 'github_api' | |
g = Github.new | |
path = `git remote show -n origin | grep Fetch | cut -d: -f2-` | |
raise "You're not in a git repo with an origin remote" if path.empty? | |
username, repo = path.split("/")[0].split(":")[1], path.split("/")[1].split(".")[0] | |
forks = g.repos.forks.list username, repo | |
usernames = forks.map(&:owner).map(&:login) | |
usernames.each do |username| | |
puts "hub fetch #{username}" | |
`hub fetch #{username}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try to get correct path, username and repo.