Created
October 25, 2009 07:44
-
-
Save mizar/217947 to your computer and use it in GitHub Desktop.
github fork repos fetch
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 perl | |
die "remote.origin.url is not a github repos\n" | |
unless `git config --get remote.origin.url` =~ | |
m{^(?:(http|git)://github\.com/|git\@github\.com\:)([\w-]+)/([\w-]+)(?:\.git)?\s*$}; | |
my ($schema, $orguser, $orgproj) = (($1 || 'git'), $2, $3); | |
my %mem = | |
map m{<a href="/([\w-]+)/([\w-]+)">}g, | |
grep m{<div class="repo">}, | |
split "\n", | |
`curl -s http://github.com/$orguser/$orgproj/network/members`; | |
die "failed to parse http://github.com/$orguser/$orgproj/network/members\n" unless %mem; | |
my %rm = | |
map m{^remote\.([\w-]+)\.url (?:http|git)://github\.com/\1/([\w-]+)(?:\.git)?\s}g, | |
`git config --get-regexp remote\..+\.url`; | |
for(sort keys %rm) { | |
next if $mem{$_} eq $rm{$_}; | |
print "remote rm $_ $rm{$_}\n"; | |
system "git remote rm $_"; | |
print "remote add $_ $mem{$_}\n" if exists $mem{$_}; | |
system "git remote add $_ $schema://github.com/$_/$mem{$_}.git" if exists $mem{$_}; | |
} | |
for(sort keys %mem) { | |
print "remote add $_ $mem{$_}\n" unless exists $rm{$_}; | |
system "git remote add $_ $schema://github.com/$_/$mem{$_}.git" unless exists $rm{$_}; | |
} | |
print "remote update\n"; | |
system "git remote update -p"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment