fixed
[ikiwiki.git] / gitremotes
blobf596c650f56f1a96b2b53ec5aeb7ad85f818b6d3
1 #!/usr/bin/perl
2 # Parses list of remotes in doc/git.mdwn, configures git to use them
3 # all. After running this, use "git remote update --prune" to pull
4 # updates from all remotes.
6 open (IN, "doc/git.mdwn") || die "doc/git.mdwn: $!";
7 while (<IN>) {
8 if (/^\*\s+\[?\[?(\w+)(?:\|\w+)?\]?\]?\s+`([^>]+)`/) {
9 # note that the remote name has to be a simple word (\w)
10 # for security/sanity reasons
11 my $remote=$1;
12 my $url=$2;
14 # check configured url to deal with it changing
15 my $info=`git remote show -n $remote`;
16 my ($oldurl)=$info=~/URL: (.*)/m;
17 if ($oldurl ne $url) {
18 system("git remote rm $remote 2>/dev/null");
19 system("git", "remote", "add", "-f", $remote, $url)
23 close IN;