Fix wrong XKeycodeToKeysym index value
[wmaker-crm.git] / update-changelog.pl
blob87ef4d6313067506491ce5f5ccf322d8b7ad999e
1 #!/usr/bin/perl
3 # Update Window Maker ChangeLog from git log
4 # Copyright (C) 2014 Window Maker Developers Team
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # DESCRIPTION
21 # This script adds the subject line and author of every commit since ChangeLog
22 # was last touched by git, in a style consistent with the entries up to version
23 # 0.92.0.
25 use warnings;
26 use strict;
27 use File::Slurp qw(read_file prepend_file edit_file);
28 use Git::Repository;
29 use Git::Repository::Log::Iterator;
30 use Text::Wrap;
32 $Text::Wrap::columns = 80;
34 my $text = read_file('ChangeLog');
35 my ($initial_entry) = $text =~ /(Changes.+?\n)\nChanges/s;
37 my $r = Git::Repository->new();
38 my $initial_commit = $r->run('log', '-n 1', '--pretty=%H', '--', 'ChangeLog');
39 my $initial_tag = $r->run('describe', '--abbrev=0', $initial_commit);
40 my $current_entry = '';
41 my $initial_author = '';
43 # start a new entry
44 if ($r->run('describe', $initial_commit) eq $initial_tag) {
45 my ($version) = $initial_tag =~ /wmaker-(.+)/;
46 $current_entry .= "Changes since version $version:\n";
47 for (my $i = 0; $i < 23 + length($version); $i++) {
48 $current_entry .= '.';
50 $current_entry .= "\n\n";
51 } else {
52 # append to an old entry
53 ($initial_author) = $initial_entry =~ /\n (.+)\n$/;
54 edit_file {s/\Q$initial_entry//} 'ChangeLog';
55 $initial_entry =~ s/\n(.+)\n$/\n/;
56 $current_entry = $initial_entry;
59 my $iter = Git::Repository::Log::Iterator->new( $r, '--reverse', "$initial_commit..HEAD");
60 my $previous_author = '';
61 my $previous_tag = $initial_tag;
63 while ( my $log = $iter->next ) {
64 my $current_author = '(' . $log->author_name . ' <' . $log->author_email . '>)';
66 # print the author of previous commit if different from current commit
67 if ($initial_author) {
68 if ($initial_author ne $current_author) {
69 chomp $current_entry;
70 $current_entry .= " $initial_author\n";
72 $initial_author = '';
74 if ($previous_author ne $current_author) {
75 if ($previous_author) {
76 $current_entry .= " $previous_author\n";
78 $previous_author = $current_author;
81 $current_entry .= wrap('- ', ' ', $log->subject . "\n");
82 my $current_commit = $log->commit;
83 my $current_tag = $r->run('describe', '--abbrev=0', $current_commit);
85 # start a new entry if new tag
86 if ($current_tag ne $previous_tag) {
87 $current_entry .= " $previous_author\n\n";
88 $previous_author = '';
89 prepend_file('ChangeLog', $current_entry, binmode => ':raw' );
90 $current_entry = '';
91 my ($version) = $current_tag =~ /wmaker-(.+)/;
92 $current_entry .= "Changes since version $version:\n";
93 for (my $i = 0; $i < 23 + length($version); $i++) {
94 $current_entry .= '.';
96 $current_entry .= "\n\n";
97 $previous_tag = $current_tag;
100 $current_entry .= " $previous_author\n\n";
101 prepend_file('ChangeLog', $current_entry, binmode => ':raw' );