diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-23 15:55:57 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-23 16:07:00 +0200 |
commit | 6e1a268c87b1140ded9eaac67bf49d85d7dab2ec (patch) | |
tree | e6f748a9d0297b193145ffa8ef2ad054215efce9 /mu-aux/gencl | |
parent | fe4bfde50d3333e5d7778a424c5e611411fabfe0 (diff) | |
download | mailutils-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-x | mu-aux/gencl | 113 |
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 @@ | |||
1 | eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"' | ||
2 | & eval 'exec perl -wS "$0" $argv:q' | ||
3 | if 0; | ||
4 | |||
5 | use strict; | ||
6 | use POSIX qw(strftime); | ||
7 | use Getopt::Long qw(:config gnu_getopt no_ignore_case); | ||
8 | |||
9 | my @append_files; | ||
10 | my $force; | ||
11 | my $verbose; | ||
12 | my $changelog_file = 'ChangeLog'; | ||
13 | |||
14 | GetOptions('append|a=s@' => \@append_files, | ||
15 | 'file|F=s' => \$changelog_file, | ||
16 | 'force|f' => \$force, | ||
17 | 'verbose|v' => \$verbose) or exit(1); | ||
18 | |||
19 | if (! -d '.git') { | ||
20 | exit 0; | ||
21 | } | ||
22 | |||
23 | my ($hash, $date) = split / /, `git log --max-count=1 --pretty=format:'%H %ad' --date=short HEAD`; | ||
24 | |||
25 | my @modlines; | ||
26 | if (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 | |||
31 | if (@modlines) { | ||
32 | $date = strftime '%Y-%m-%d', localtime; | ||
33 | } | ||
34 | |||
35 | my @header; | ||
36 | |||
37 | push @header, "$date Automatically generated <bug-mailutils\@gnu.org>"; | ||
38 | push @header, ''; | ||
39 | push @header, "\tHEAD $hash"; | ||
40 | push @header, ''; | ||
41 | |||
42 | my %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 | |||
53 | if (@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 | |||
63 | sub 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 | |||
77 | if (!$force && headcmp($changelog_file, @header)) { | ||
78 | exit 0; | ||
79 | } | ||
80 | |||
81 | print " GEN $changelog_file\n" if $verbose; | ||
82 | close STDOUT; | ||
83 | |||
84 | open(STDOUT, '>', $changelog_file) | ||
85 | or die "Can't open $changelog_file for writing: $!"; | ||
86 | |||
87 | for (@header) { | ||
88 | print "$_\n"; | ||
89 | } | ||
90 | |||
91 | system(@ARGV); | ||
92 | foreach 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 | |||
106 | print "\f\nLocal Variables:\n"; | ||
107 | print <<'EOT'; | ||
108 | mode: change-log | ||
109 | version-control: never | ||
110 | buffer-read-only: t | ||
111 | End: | ||
112 | EOT | ||
113 | ; | ||