Skip to content

Commit

Permalink
fix up wikidoc and generated README
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Apr 11, 2012
1 parent 177abbe commit 3de5a16
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 57 deletions.
3 changes: 1 addition & 2 deletions README.pod
Expand Up @@ -20,8 +20,7 @@ This is a "before release" Dist::Zilla plugin that ensures that your Changes
file actually has some content since the last release. If it doesn't find any, file actually has some content since the last release. If it doesn't find any,
it will abort the release process. it will abort the release process.


This can be contrasted to This can be contrasted to L<Dist::Zilla::Plugin::Test::ChangesHasContent>, which
LE<lt>[Test::ChangesHasContent]E<verbar>Dist::Zilla::Plugin::Test::ChangesHasContentE<gt>, which
generates a test to perform the check. generates a test to perform the check.


The algorithm is very naive. It looks for an unindented line starting with The algorithm is very naive. It looks for an unindented line starting with
Expand Down
3 changes: 1 addition & 2 deletions lib/Dist/Zilla/Plugin/CheckChangesHasContent.pm
Expand Up @@ -89,8 +89,7 @@ This is a "before release" Dist::Zilla plugin that ensures that your Changes
file actually has some content since the last release. If it doesn't find any, file actually has some content since the last release. If it doesn't find any,
it will abort the release process. it will abort the release process.
This can be contrasted to This can be contrasted to [Dist::Zilla::Plugin::Test::ChangesHasContent], which
L<[Test::ChangesHasContent]|Dist::Zilla::Plugin::Test::ChangesHasContent>, which
generates a test to perform the check. generates a test to perform the check.
The algorithm is very naive. It looks for an unindented line starting with The algorithm is very naive. It looks for an unindented line starting with
Expand Down
101 changes: 48 additions & 53 deletions lib/Dist/Zilla/Plugin/Test/ChangesHasContent.pm
Expand Up @@ -42,49 +42,7 @@ __PACKAGE__->meta->make_immutable;


1; 1;


__DATA__ # Pod must be before DATA
___[ xt/release/changes_has_content.t ]___
#!perl
use Test::More tests => 2;
note 'Checking Changes';
my $changes_file = '{{$changelog}}';
my $newver = '{{$newver}}';
SKIP: {
ok(-e $changes_file, "$changes_file file exists")
or skip 'Changes is missing', 1;
ok(_get_changes($newver), "$changes_file has content for $newver");
}
done_testing;
# _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit
# by Jerome Quelin
sub _get_changes
{
my $newver = shift;
# parse changelog to find commit message
open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!";
my $changelog = join('', <$fh>);
close $fh;
my @content =
grep { /^$newver(?:\s+|$)/ ... /^\S/ } # from newver to un-indented
split /\n/, $changelog;
shift @content; # drop the version line
# drop unindented last line and trailing blank lines
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ );
# return number of non-blank lines
return scalar @content;
}
__END__


=begin wikidoc =begin wikidoc
Expand All @@ -96,21 +54,14 @@ __END__
= DESCRIPTION = DESCRIPTION
This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the following file: This is an extension of [Dist::Zilla::Plugin::InlineFiles], providing the following file:
=over 4
=item *
xt/release/changes_has_content.t * xt/release/changes_has_content.t
=back
This test ensures ensures that your Changes file actually has some content This test ensures ensures that your Changes file actually has some content
since the last release. since the last release.
This can be contrasted to This can be contrasted to [Dist::Zilla::Plugin::CheckChangesHasContent], which
L<[CheckChangesHasContent]|Dist::Zilla::Plugin::CheckChangesHasContent>, which
performs the check at release time, halting the release process if content is performs the check at release time, halting the release process if content is
missing. Performing the check as a test makes it possible to check more missing. Performing the check as a test makes it possible to check more
frequently, and closer to the point of development. frequently, and closer to the point of development.
Expand Down Expand Up @@ -149,3 +100,47 @@ the name with the {changelog} argument:
=cut =cut


__DATA__
___[ xt/release/changes_has_content.t ]___
#!perl
use Test::More tests => 2;
note 'Checking Changes';
my $changes_file = '{{$changelog}}';
my $newver = '{{$newver}}';
SKIP: {
ok(-e $changes_file, "$changes_file file exists")
or skip 'Changes is missing', 1;
ok(_get_changes($newver), "$changes_file has content for $newver");
}
done_testing;
# _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit
# by Jerome Quelin
sub _get_changes
{
my $newver = shift;
# parse changelog to find commit message
open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!";
my $changelog = join('', <$fh>);
close $fh;
my @content =
grep { /^$newver(?:\s+|$)/ ... /^\S/ } # from newver to un-indented
split /\n/, $changelog;
shift @content; # drop the version line
# drop unindented last line and trailing blank lines
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ );
# return number of non-blank lines
return scalar @content;
}
__END__

0 comments on commit 3de5a16

Please sign in to comment.