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