TODO++
[ikiwiki] / gitremotes
CommitLineData
d135bd3f
JH
1#!/usr/bin/perl
2# Parses list of remotes in doc/git.mdwn, configures git to use them
958e8323
JH
3# all. After running this, use "git remote update --prune" to pull
4# updates from all remotes.
d135bd3f
JH
5
6open (IN, "doc/git.mdwn") || die "doc/git.mdwn: $!";
7while (<IN>) {
0c04e936 8 if (/^\*\s+\[?\[?(\w+)(?:\|\w+)?\]?\]?\s+`([^>]+)`/) {
d135bd3f
JH
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;
13
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");
2d60e553 19 system("git", "remote", "add", $remote, $url);
c2c57f0c
SM
20 system("git", "config", "remote.$remote.tagopt",
21 "--no-tags");
2d60e553 22 system("git", "fetch", $remote);
d135bd3f
JH
23 }
24 }
25}
26close IN;