1#!/usr/bin/perl
2
3# git log --pretty=fuller --no-color --date=short --decorate=full
4
5my @mname = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
6             'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
7
8sub nicedate {
9    my ($date)=$_;
10
11    if($date =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
12        return sprintf("%d %s %4d", $3, $mname[$2-1], $1);
13    }
14    return $date;
15}
16
17print
18'                                  _   _ ____  _
19                              ___| | | |  _ \| |
20                             / __| | | | |_) | |
21                            | (__| |_| |  _ <| |___
22                             \___|\___/|_| \_\_____|
23
24                                  Changelog
25';
26
27my $line;
28my $tag;
29while(<STDIN>) {
30    my $l = $_;
31
32    if($l =~/^commit ([[:xdigit:]]*) ?(.*)/) {
33        $co = $1;
34        my $ref = $2;
35        if ($ref =~ /refs\/tags\/curl-([0-9_]*)/) {
36            $tag = $1;
37            $tag =~ tr/_/./;
38        }
39    }
40    elsif($l =~ /^Author: *(.*) +</) {
41        $a = $1;
42    }
43    elsif($l =~ /^Commit: *(.*) +</) {
44        $c = $1;
45    }
46    elsif($l =~ /^CommitDate: (.*)/) {
47        $date = nicedate($1);
48    }
49    elsif($l =~ /^(    )(.*)/) {
50        my $extra;
51        if ($tag) {
52            # Version entries have a special format
53            print "\nVersion " . $tag." ($date)\n";
54            $oldc = "";
55            $tag = "";
56        }
57        if($a ne $c) {
58            $extra=sprintf("\n- [%s brought this change]\n\n  ", $a);
59        }
60        else {
61            $extra="\n- ";
62        }
63        if($co ne $oldco) {
64            if($c ne $oldc) {
65                print "\n$c ($date)$extra";
66            }
67            else {
68                print "$extra";
69            }
70            $line =0;
71        }
72
73        $oldco = $co;
74        $oldc = $c;
75        $olddate = $date;
76        if($line++) {
77            print "  ";
78        }
79        print $2."\n";
80    }
81}
82