line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
811350
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::CheckChangesHasContent; |
4
|
|
|
|
|
|
|
# ABSTRACT: Ensure Changes has content before releasing |
5
|
|
|
|
|
|
|
our $VERSION = '0.009'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Dependencies |
8
|
1
|
|
|
1
|
|
4
|
use Dist::Zilla 2.100950 (); # XXX really the next release after this date |
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
19
|
|
9
|
1
|
|
|
1
|
|
3
|
use autodie 2.00; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
3229
|
use File::pushd 0 (); |
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
26
|
|
11
|
1
|
|
|
1
|
|
4
|
use Moose 0.99; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
5033
|
use namespace::autoclean 0.09; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# extends, roles, attributes, etc. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::BeforeRelease'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has changelog => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => 'Str', |
21
|
|
|
|
|
|
|
default => 'Changes' |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has trial_token => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Str', |
27
|
|
|
|
|
|
|
default => '-TRIAL' |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# methods |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub before_release { |
33
|
5
|
|
|
5
|
0
|
425864
|
my $self = shift; |
34
|
5
|
|
|
|
|
349
|
my $changes_file = $self->changelog; |
35
|
5
|
|
|
|
|
195
|
my $newver = $self->zilla->version; |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
250
|
$self->log("Checking Changes"); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
3070
|
$self->zilla->ensure_built_in; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# chdir in |
42
|
5
|
|
|
|
|
692
|
my $wd = File::pushd::pushd($self->zilla->built_in); |
43
|
|
|
|
|
|
|
|
44
|
5
|
50
|
|
|
|
1289
|
if ( ! -e $changes_file ) { |
|
|
100
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
$self->log_fatal("No $changes_file file found"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ( $self->_get_changes ) { |
48
|
3
|
|
|
|
|
67
|
$self->log("$changes_file OK"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
2
|
|
|
|
|
49
|
$self->log_fatal("$changes_file has no content for $newver"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
1391
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit |
58
|
|
|
|
|
|
|
# by Jerome Quelin |
59
|
|
|
|
|
|
|
sub _get_changes { |
60
|
5
|
|
|
5
|
|
11
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# parse changelog to find commit message |
63
|
5
|
|
|
|
|
243
|
my $changelog = Dist::Zilla::File::OnDisk->new( { name => $self->changelog } ); |
64
|
5
|
|
|
|
|
2824
|
my $newver = $self->zilla->version; |
65
|
5
|
|
|
|
|
400
|
my $trial_token = $self->trial_token; |
66
|
|
|
|
|
|
|
my @content = |
67
|
5
|
|
|
|
|
172
|
grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented |
|
37
|
|
|
|
|
5278
|
|
68
|
|
|
|
|
|
|
split /\n/, $changelog->content; |
69
|
5
|
|
|
|
|
19
|
shift @content; # drop the version line |
70
|
|
|
|
|
|
|
# drop unindented last line and trailing blank lines |
71
|
5
|
|
100
|
|
|
151
|
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# return number of non-blank lines |
74
|
5
|
|
|
|
|
207
|
return scalar @content; |
75
|
|
|
|
|
|
|
} # end _get_changes |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Dist::Zilla::Plugin::CheckChangesHasContent - Ensure Changes has content before releasing |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 0.009 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# in dist.ini |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
[CheckChangesHasContent] |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is a "before release" Dist::Zilla plugin that ensures that your Changes |
104
|
|
|
|
|
|
|
file actually has some content since the last release. If it doesn't find any, |
105
|
|
|
|
|
|
|
it will abort the release process. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This can be contrasted to L<Dist::Zilla::Plugin::Test::ChangesHasContent>, which |
108
|
|
|
|
|
|
|
generates a test to perform the check. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The algorithm is very naive. It looks for an unindented line starting with |
111
|
|
|
|
|
|
|
the version to be released. It then looks for any text from that line until |
112
|
|
|
|
|
|
|
the next unindented line (or the end of the file), ignoring whitespace. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
For example, in the file below, algorithm will find "- blah blah blah": |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Changes file for Foo-Bar |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
{{$NEXT}} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
- blah blah blah |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
0.001 Wed May 12 13:49:13 EDT 2010 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
- the first release |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
If you had nothing but whitespace between C<{{$NEXT}}> and C<0.001>, |
127
|
|
|
|
|
|
|
the release would be halted. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If you name your change log something other than "Changes", you can configure |
130
|
|
|
|
|
|
|
the name with the C<changelog> argument: |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
[CheckChangesHasContent] |
133
|
|
|
|
|
|
|
changelog = ChangeLog |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=for Pod::Coverage before_release |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
* L<Dist::Zilla::Plugin::Test::ChangesHasContent> |
140
|
|
|
|
|
|
|
* L<Dist::Zilla> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SUPPORT |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
149
|
|
|
|
|
|
|
at L<https://github.com/dagolden/Dist-Zilla-Plugin-CheckChangesHasContent/issues>. |
150
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 Source Code |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
155
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<https://github.com/dagolden/Dist-Zilla-Plugin-CheckChangesHasContent> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
git clone https://github.com/dagolden/Dist-Zilla-Plugin-CheckChangesHasContent.git |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 AUTHORS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=for stopwords Randy Stauner |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Randy Stauner <randy@magnificent-tears.com> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by David Golden. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This is free software, licensed under: |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |