From: Graham Knop Date: Thu, 12 Nov 2015 09:26:02 +0000 (-0500) Subject: include changes text in release commit and tag X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6b7b384edb5edad4f74a1e30a7c6bad569ba2b8;p=p5sagit%2FDistar.git include changes text in release commit and tag --- diff --git a/helpers/get-changelog b/helpers/get-changelog new file mode 100755 index 0000000..7d701d4 --- /dev/null +++ b/helpers/get-changelog @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings FATAL => 'all'; +use Getopt::Long qw(:config gnu_getopt); +GetOptions( + "p|prefix=s@" => \(my $prefix = []), + "s|suffix=s@" => \(my $suffix = []), +) or die "Error in command line arguments\n"; + +my $version = shift or die "no version specified!\n"; +my $changelog = @ARGV ? shift : 'Changes'; + +$version =~ s/\Av//; + +open my $fh, '<:raw', $changelog + or die "can't open $changelog: $!\n"; +my $version_log = ''; +my $found_version; +while (my $line = <$fh>) { + if ($found_version) { + last + if $line =~ /^\S/; + $version_log .= $line; + } + elsif ($line =~ /^v?\Q$version\E/) { + $found_version = 1; + } +} +close $fh; +die "couldn't find heading for $version in $changelog!\n" + unless $found_version; + +$version_log =~ s/\r\n?/\n/g; +$version_log =~ s/\n+\z//; + +s/\n\z// + for @$prefix, @$suffix; + +print join("\n\n", @$prefix, $version_log, @$suffix) . "\n"; diff --git a/lib/Distar.pm b/lib/Distar.pm index 1b0e5cf..f6d02d5 100644 --- a/lib/Distar.pm +++ b/lib/Distar.pm @@ -222,6 +222,7 @@ END_FRAG DISTTEST_MAKEFILE_PARAMS => '', AUTHORS => $self->quote_literal(join(', ', @$authors)), LICENSES => join(' ', map $self->quote_literal($_), @$licenses), + GET_CHANGELOG => '$(ABSPERLRUN) $(HELPERS)/get-changelog $(VERSION) $(CHANGELOG)', ); my $dist_test = $self->SUPER::dist_test(@_); @@ -245,8 +246,8 @@ releasetest: $(MAKE) disttest RELEASE_TESTING=1 DISTTEST_MAKEFILE_PARAMS="PREREQ_FATAL=1" PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\"" release: preflight $(MAKE) releasetest - git commit -a -m "Release commit for $(VERSION)" - git tag v$(VERSION) -m "release v$(VERSION)" + $(GET_CHANGELOG) -p"Release commit for $(VERSION)" | git commit -a -F - + $(GET_CHANGELOG) -p"release v$(VERSION)" | git tag -a -F - "v$(VERSION)" $(RM_RF) $(DISTVNAME) $(MAKE) $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE)