From: Graham Knop Date: Thu, 21 Aug 2014 14:01:11 +0000 (-0400) Subject: add nextrelease command to add version heading to changelog X-Git-Tag: v0.002000~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7a786518f33eed0a2a1156b8ea1e685ce688ff5;p=p5sagit%2FDistar.git add nextrelease command to add version heading to changelog --- diff --git a/helpers/add-changelog-heading b/helpers/add-changelog-heading new file mode 100755 index 0000000..85a0f9d --- /dev/null +++ b/helpers/add-changelog-heading @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +use strict; +use warnings FATAL => 'all'; + +my $version = shift; +my @ymd = (gmtime)[5,4,3]; +$ymd[0] += 1900; +$ymd[1] += 1; +my $changes_line = sprintf "%s - %i-%02i-%02i\n", $version, @ymd; + +foreach my $changes (@ARGV) { + print "Adding $version heading to $changes.\n"; + open my $fh, '+<', $changes + or die "Can't open $changes: $!"; + my $content = ''; + my $done; + local $/ = $/; + while (<$fh>) { + if ($done) { + undef $/; + } + elsif (/^v?(\d+(?:\.\d+)*)(\s+|$)/) { + if ($1 eq $version) { + die "$changes already has an entry for $version!\n"; + } + else { + die "No changelog entries found before $1!\n"; + } + } + elsif (/^\s+[-*+#]/) { + $content .= $changes_line; + $done = 1; + } + $content .= $_; + } + + seek $fh, 0, 0; + truncate $fh, 0; + print { $fh } $content; + close $fh; +} diff --git a/lib/Distar.pm b/lib/Distar.pm index ae72c84..f8e18e7 100644 --- a/lib/Distar.pm +++ b/lib/Distar.pm @@ -169,6 +169,9 @@ END disttest: distmanicheck distmanicheck: create_distdir cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck" +nextrelease: + $(ABSPERLRUN) Distar/helpers/add-changelog-heading $(VERSION) Changes + git add -p Changes END if (open my $fh, '<', 'maint/Makefile.include') {