From fd7ba0ad86935ec6baf61744b2e950fc669ae48b Mon Sep 17 00:00:00 2001 From: mstsirkin Date: Tue, 11 Mar 2014 09:14:06 +0000 Subject: getchangelog.pl: script to generate changelog simply output into text file uses REVISION history to guess revision range Signed-off-by: Michael S. Tsirkin git-svn-id: https://tools.oasis-open.org/version-control/svn/virtio@317 0c8fb4dd-22a2-4bb5-bc14-6c75a5f43652 --- getchangelog.pl | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100755 getchangelog.pl diff --git a/getchangelog.pl b/getchangelog.pl new file mode 100755 index 0000000..e72645e --- /dev/null +++ b/getchangelog.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +use strict; + +my $rev = undef; +if ($#ARGV >= 0) { + $rev = shift @ARGV; +} else { + open(REV, "git svn log REVISION|") || die; + while () { + next unless (m/^(r[0-9]+)/); + #top revision is WD, skip it + if (not defined $rev) { + $rev = $1; + next; + } else { + $rev = $1; + last; + } + } +} + +die unless $rev =~ m/^r([0-9]+)$/; +$rev = $1; + +sub escapelatex { + my $s = shift; + $s =~ s/[\\]/\\textbackslash /go; + $s =~ s/([&#%{}\$])/\\$1/go; + $s =~ s/[~]/\\~{}/go; + $s =~ s/(https?:\S*)/\\url{$1}/go; + return $s; +} + +#map editors to authors +my %editors = {}; +$editors{'rusty'} = 'Rusty Russell '; +$editors{'hornet'} = 'Pawel Moll '; +$editors{'cornelia.huck'} = 'Cornelia Huck '; +$editors{'mstsirkin'} = 'Michael S. Tsirkin '; + +my $cl = ""; +my $signoff = undef; +my $editor = undef; +my $date = undef; +my $r = undef; +open(LOG, "git svn log *tex|") || die; +my $line = undef; +while () { + if (m/^------------------------------------------------------------------------$/) { + next if ($cl eq ""); + # act on it + my $author; + if (defined $signoff) { + $author = $signoff; + } else { + $author = $editors{$editor}; + } + #strip mail info + $author =~ s/\s*<.*//; + $cl = escapelatex($cl); + print "$r & $date & $author & { $cl } \\\\\n"; + print "\\hline\n"; + + $cl = ""; + $signoff = undef; + $editor = undef; + $date = undef; + $r = undef; + + $line = 0; + next; + } + $line++; +#r164 | mstsirkin | 2013-12-08 14:30:55 +0200 (Sun, 08 Dec 2013)| 6 lines + + if ($line eq 1) { + die unless (m/^r[0-9]/); + my @rinfo = split(/\s*\Q|\E\s*/, $_); + $r = $rinfo[0]; + + die unless $r =~ m/^r([0-9]+)$/; + $r = $1; + last if ($r <= $rev); + + $editor = $rinfo[1]; + $date = $rinfo[2]; + die unless ($date =~ m/^[^(]*\([^,]*,\s*([^)]+)\)\s*$/); + $date = $1; + next; + } + next if (m/^$/); + + # First signature is the author: needed? + # ignore for now + #if (not defined $signoff and m/^Signed-off-by:\s*(.*)/) { + # $signoff = $1; + #} + # skip signatures + next if (m/^\s*[A-Z][A-Za-z-]*-by:/); + + + # fix bug: wrong date in some commit logs + if (/Change accepted on VIRTIO TC Meeting, 3 December 2013/) { + $_ = "Change accepted on Virtio TC Meeting Minutes: Feb 25, 2014\n"; + } + + $cl .= $_; +} -- cgit v1.2.3