Index: trunk/tools/mediawiki-svn-to-git-gateway/update-git.pl |
— | — | @@ -0,0 +1,29 @@ |
| 2 | +#!/usr/bin/env perl |
| 3 | +use feature ':5.10'; |
| 4 | +use strict; |
| 5 | +use warnings; |
| 6 | + |
| 7 | +my $repository = '/home/avar/src/mediawiki'; |
| 8 | + |
| 9 | +chdir $repository or die $!; |
| 10 | + |
| 11 | +my @last_irc_revs = last_irc_revs(); |
| 12 | +my $last_git_rev = last_git_rev(); |
| 13 | + |
| 14 | +if ($last_irc_revs[-1] != $last_git_rev) { |
| 15 | + say "Need to update from $last_irc_revs[-1] to $last_git_rev (" . ($last_irc_revs[-1] - $last_git_rev) . " revisions)"; |
| 16 | + system 'git svn rebase'; |
| 17 | +} |
| 18 | + |
| 19 | +sub last_irc_revs |
| 20 | +{ |
| 21 | + my @lines = `tail -n1000 /home/avar/.irssi/logs/freenode/#mediawiki.log*`; |
| 22 | + my @rev = map { /r(\d+)/; $1 } grep { /^\d+:\d+ < CIA-\d+> \S+ \* r(\d+).*/ } @lines; |
| 23 | + return @rev; |
| 24 | +} |
| 25 | + |
| 26 | +sub last_git_rev |
| 27 | +{ |
| 28 | + my ($ver) = `git svn log --oneline --limit 1` =~ /r(\d+)/; |
| 29 | + return $ver; |
| 30 | +} |