summaryrefslogtreecommitdiff
path: root/gitremotes
blob: d49cf2d9eff41cc001d9b5c6145b1d9a20e69050 (plain)
  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. my $error=0;
  5. open (IN, "doc/git.mdwn") || die "doc/git.mdwn: $!";
  6. while (<IN>) {
  7. if (/^\*\s+\[?\[?(\w+)(?:\|\w+)?\]?\]?\s+`([^>]+)`/) {
  8. # note that the remote name has to be a simple word (\w)
  9. # for security/sanity reasons
  10. my $remote=$1;
  11. my $url=$2;
  12. # check configured url to deal with it changing
  13. my $info=`git remote show -n $remote`;
  14. my ($oldurl)=$info=~/URL: (.*)/m;
  15. my $r;
  16. if ($oldurl ne $url) {
  17. system("git remote rm $remote 2>/dev/null");
  18. $r = system("git", "remote", "add", "-f", $remote, $url)
  19. }
  20. else {
  21. $r = system("git", "fetch", "--no-tag", $remote);
  22. }
  23. if ($r != 0) {
  24. print "$remote failed\n";
  25. }
  26. $error |= $r;
  27. # drop stale tracking branches
  28. system("git", "remote", "prune", $remote);
  29. }
  30. }
  31. close IN;
  32. exit $error;