summaryrefslogtreecommitdiff
path: root/mu-aux/gencl
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-03-23 15:55:57 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-03-23 16:07:00 +0200
commit6e1a268c87b1140ded9eaac67bf49d85d7dab2ec (patch)
treee6f748a9d0297b193145ffa8ef2ad054215efce9 /mu-aux/gencl
parentfe4bfde50d3333e5d7778a424c5e611411fabfe0 (diff)
downloadmailutils-6e1a268c87b1140ded9eaac67bf49d85d7dab2ec.tar.gz
mailutils-6e1a268c87b1140ded9eaac67bf49d85d7dab2ec.tar.bz2
Make sure ChangeLog is built by make
* Makefile.am: Mark ChangeLog as noinst_DATA to trigger its rule. Rewrite the ChangeLog rule using a wrapper over gitlog-to-changelog, which rewrites the file only when needed. (dist-hook): Fail if there are uncommitted changes. * mu-aux/gencl: New file. * maint.mk: Remove.
Diffstat (limited to 'mu-aux/gencl')
-rwxr-xr-xmu-aux/gencl113
1 files changed, 113 insertions, 0 deletions
diff --git a/mu-aux/gencl b/mu-aux/gencl
new file mode 100755
index 000000000..af6056bd5
--- /dev/null
+++ b/mu-aux/gencl
@@ -0,0 +1,113 @@
1eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
2 & eval 'exec perl -wS "$0" $argv:q'
3 if 0;
4
5use strict;
6use POSIX qw(strftime);
7use Getopt::Long qw(:config gnu_getopt no_ignore_case);
8
9my @append_files;
10my $force;
11my $verbose;
12my $changelog_file = 'ChangeLog';
13
14GetOptions('append|a=s@' => \@append_files,
15 'file|F=s' => \$changelog_file,
16 'force|f' => \$force,
17 'verbose|v' => \$verbose) or exit(1);
18
19if (! -d '.git') {
20 exit 0;
21}
22
23my ($hash, $date) = split / /, `git log --max-count=1 --pretty=format:'%H %ad' --date=short HEAD`;
24
25my @modlines;
26if (open(my $fd, '-|', 'git diff-index --name-status HEAD 2>/dev/null')) {
27 chomp(@modlines = map {chomp; [split /\s+/, $_, 2]} <$fd>);
28 close $fd;
29}
30
31if (@modlines) {
32 $date = strftime '%Y-%m-%d', localtime;
33}
34
35my @header;
36
37push @header, "$date Automatically generated <bug-mailutils\@gnu.org>";
38push @header, '';
39push @header, "\tHEAD $hash";
40push @header, '';
41
42my %status = (
43 A => 'New file',
44 C => 'Copied file',
45 D => 'Removed file',
46 M => 'Changed',
47 R => 'Renamed',
48 T => 'Type change',
49 U => 'Unmerged',
50 X => 'Unknown'
51);
52
53if (@modlines) {
54 push @header, "\tUncommitted changes:";
55 push @header, '';
56
57 push @header, map {
58 "\t* $_->[1]: " . ($status{$_->[0]} || 'Unknown') . ";"
59 } @modlines;
60 push @header, '';
61}
62
63sub headcmp {
64 my $file = shift;
65 if (open(my $fd, '<', $changelog_file)) {
66 while (<$fd>) {
67 my $line = shift;
68 last unless defined($line);
69 chomp;
70 return 0 unless $line eq $_;
71 }
72 return 1 unless @_;
73 }
74 return 0;
75}
76
77if (!$force && headcmp($changelog_file, @header)) {
78 exit 0;
79}
80
81print " GEN $changelog_file\n" if $verbose;
82close STDOUT;
83
84open(STDOUT, '>', $changelog_file)
85 or die "Can't open $changelog_file for writing: $!";
86
87for (@header) {
88 print "$_\n";
89}
90
91system(@ARGV);
92foreach my $file (@append_files) {
93 if (open(my $fd, '<', $file)) {
94 while (<$fd>) {
95 chomp;
96 last if /^Local Variables:/;
97 next if /^\f$/;
98 print "$_\n";
99 }
100 close $fd;
101 } else {
102 warn "can't open $file: $!";
103 }
104}
105
106print "\f\nLocal Variables:\n";
107print <<'EOT';
108mode: change-log
109version-control: never
110buffer-read-only: t
111End:
112EOT
113;

Return to:

Send suggestions and report system problems to the System administrator.