summaryrefslogtreecommitdiff
path: root/getchangelog.pl
blob: e72645eb162f2b60fae38dc6ba821624fa57ba17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl

use strict;

my $rev = undef;
if ($#ARGV >= 0) {
	$rev = shift @ARGV;
} else {
	open(REV, "git svn log REVISION|") || die;
	while (<REV>) {
		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 <rusty@au1.ibm.com>';
$editors{'hornet'} = 'Pawel Moll <pawel.moll@arm.com>';
$editors{'cornelia.huck'} = 'Cornelia Huck <cornelia.huck@de.ibm.com>';
$editors{'mstsirkin'} = 'Michael S. Tsirkin <mst@redhat.com>';

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 (<LOG>) {
	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 .= $_;
}