]> sipb.mit.edu Git - ikiwiki.git/blob - gitremotes
update as command syntax has changed
[ikiwiki.git] / gitremotes
1 #!/usr/bin/perl
2 # Parses list of remotes in doc/git.mdwn, configures git to use them
3 # all, and fetches updates from them.
4
5 my $error=0;
6
7 open (IN, "doc/git.mdwn") || die "doc/git.mdwn: $!";
8 while (<IN>) {
9         if (/^\*\s+\[?\[?(\w+)(?:\|\w+)?\]?\]?\s+`([^>]+)`/) {
10                 # note that the remote name has to be a simple word (\w)
11                 # for security/sanity reasons
12                 my $remote=$1;
13                 my $url=$2;
14
15                 # check configured url to deal with it changing
16                 my $info=`git remote show -n $remote`;
17                 my ($oldurl)=$info=~/URL: (.*)/m;
18                 if ($oldurl ne $url) {
19                         system("git remote rm $remote 2>/dev/null");
20                         $error |= system("git", "remote", "add", "-f", $remote, $url);
21                 }
22                 else {
23                         $error |= system("git", "fetch", $remote);
24                 }
25         }
26 }
27 close IN;
28
29 exit $error;