3 use warnings FATAL => 'all';
4 use Getopt::Long qw(:config gnu_getopt);
7 ) or die("Error in command line arguments\n");
10 my @ymd = (gmtime)[5,4,3];
13 my $changes_line = sprintf "%s - %i-%02i-%02i", $version, @ymd;
15 foreach my $changes (@ARGV) {
16 print "Adding $version heading to $changes.\n";
17 open my $fh, '+<:raw', $changes
18 or die "Can't open $changes: $!";
24 if (defined $context) {
27 $content .= $_ . <$fh>;
32 elsif (/^v?(\d+(?:\.\d+)*)(\s+|$)/) {
34 die "$changes already has an entry for $version!\n";
37 die "No changelog entries found before $1!\n";
40 elsif (/^\s+[-*+#]/) {
41 $content .= $changes_line;
42 $content .= (/(\r?\n)/ || $content =~ /(\r?\n)/) ? $1 : "\n";
50 print { $fh } $content;
54 local $ENV{GIT_DIFF_OPTS} = "-u$context";
55 system qw(git add -p), $changes;