xref: /curl/scripts/log2changes.pl (revision 2bc1d775)
1#!/usr/bin/env perl
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
25
26# git log --pretty=fuller --no-color --date=short --decorate=full
27
28my @mname = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
29             'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' );
30
31sub nicedate {
32    my ($date)=$_;
33
34    if($date =~ /(\d\d\d\d)-(\d\d)-(\d\d)/) {
35        return sprintf("%d %s %4d", $3, $mname[$2-1], $1);
36    }
37    return $date;
38}
39
40sub printmsg {
41    my ($p, $msg)=@_;
42    while(length($msg) > 77) {
43        print $p.substr($msg, 0, 77, "")."\n";
44        $p="  ";
45    }
46    if($msg eq "") {
47        $p = "";
48    }
49    print "$p$msg\n";
50}
51
52print
53'                                  _   _ ____  _
54                              ___| | | |  _ \| |
55                             / __| | | | |_) | |
56                            | (__| |_| |  _ <| |___
57                             \___|\___/|_| \_\_____|
58
59                                  Changelog
60';
61
62my $tag;
63while(<STDIN>) {
64    my $l = $_;
65
66    if($l =~/^commit ([[:xdigit:]]*) ?(.*)/) {
67        $co = $1;
68        my $ref = $2;
69        if ($ref =~ /refs\/tags\/curl-([0-9_]*)/) {
70            $tag = $1;
71            $tag =~ tr/_/./;
72        }
73    }
74    elsif($l =~ /^Author: *(.*) +</) {
75        $c = $1;
76    }
77    elsif($l =~ /^CommitDate: (.*)/) {
78        $date = nicedate($1);
79    }
80    elsif($l =~ /^(    )(.*)/) {
81        my $pref = "  ";
82        if ($tag) {
83            # Version entries have a special format
84            print "\nVersion " . $tag." ($date)\n";
85            $oldc = "";
86            $tag = "";
87        }
88        if($co ne $oldco) {
89            if($c ne $oldc) {
90                print "\n$c ($date)\n\n";
91            }
92            else {
93                print "\n";
94            }
95            $pref = "- ";
96        }
97
98        $oldco = $co;
99        $oldc = $c;
100        $olddate = $date;
101        printmsg($pref, $2);
102    }
103}
104