]> git.sur5r.net Git - bacula/bacula/blob - bacula/release/git2changelog.pl
f371deb0c73827e63cf20edcd2ffb61f39c2bd78
[bacula/bacula] / bacula / release / git2changelog.pl
1 #!/usr/bin/perl -w
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 =head USAGE
7     
8     ./git2changelog.pl Release-3.0.1..Release-3.0.2
9
10  For bweb ReleaseNotes, use
11     FORBWEB=1 ./git2changelog.pl Release-3.0.1..Release-3.0.2
12
13 =cut
14
15 use strict;
16 use POSIX q/strftime/;
17
18 my $d='';
19 my $cur;
20 my %elt;
21 my $last_txt='';
22 my %bugs;
23 my $refs = shift || '';
24 my $for_bweb = $ENV{FORBWEB}?1:0;
25 open(FP, "git log --no-merges --pretty=format:'%at: %s' $refs|") or die "Can't run git log $!";
26 while (my $l = <FP>) {
27
28     # remove non useful messages
29     next if ($l =~ /(tweak|typo|cleanup|regress:|again|.gitignore|fix compilation|technotes)/ixs);
30     next if ($l =~ /update (version|technotes|kernstodo|projects|releasenotes|version|home|release|todo|notes|changelog|tpl|configure)/i);
31
32     next if ($l =~ /bacula-web:/);
33
34     if ($for_bweb) {
35         next if ($l !~ /bweb/ixs);
36         $l =~ s/bweb: *//ig;
37     } else {
38         next if ($l =~ /bweb:/ixs);
39     }
40
41     # keep list of fixed bugs
42     if ($l =~ /#(\d+)/) {
43         $bugs{$1}=1;
44     }
45
46     # remove old commit format
47     $l =~ s/^(\d+): (kes|ebl)  /$1: /;
48
49     if ($l =~ /(\d+): (.+)/) {
50         # use date as 01Jan70
51         my $dnow = strftime('%d%b%y', localtime($1));
52         my $cur = strftime('%Y%m%d', localtime($1));
53         my $txt = $2;
54
55         # avoid identical multiple commit message
56         next if ($last_txt eq $txt);
57         $last_txt = $txt;
58
59         # We format the string on 79 caracters
60         $txt =~ s/\s\s+/ /g;
61         $txt =~ s/.{70,77} /$&\n  /g;
62
63         # if we are the same day, just add entry
64         if ($dnow ne $d) {
65             $d = $dnow;
66             if (!exists $elt{$cur}) {
67                 push @{$elt{$cur}}, "\n\n$dnow";
68             }
69         }
70         push @{$elt{$cur}},  " - $txt";
71
72     } else {
73         print STDERR "invalid format: $l\n";
74     }
75 }
76
77 close(FP);
78
79 foreach my $d (sort {$b <=> $a} keys %elt) {
80     print join("\n", @{$elt{$d}});
81 }
82
83 print "\n\nBugs fixed/closed since last release:\n";
84 print join(" ", sort keys %bugs), "\n";