line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
605608
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
3
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::CheckChangesHasContent; |
4
|
|
|
|
|
|
|
# ABSTRACT: Ensure Changes has content before releasing |
5
|
|
|
|
|
|
|
our $VERSION = '0.010'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Dependencies |
8
|
1
|
|
|
1
|
|
3
|
use Dist::Zilla 2.100950 (); # XXX really the next release after this date |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
19
|
|
9
|
1
|
|
|
1
|
|
4
|
use autodie 2.00; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
2917
|
use File::pushd 0 (); |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
4
|
use Moose 0.99; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
4429
|
use namespace::autoclean 0.09; |
|
1
|
|
|
|
|
17
|
|
|
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
|
485536
|
my $self = shift; |
34
|
5
|
|
|
|
|
235
|
my $changes_file = $self->changelog; |
35
|
5
|
|
|
|
|
141
|
my $newver = $self->zilla->version; |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
181
|
$self->log("Checking Changes"); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
2133
|
$self->zilla->ensure_built_in; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# chdir in |
42
|
5
|
|
|
|
|
431
|
my $wd = File::pushd::pushd($self->zilla->built_in); |
43
|
|
|
|
|
|
|
|
44
|
5
|
50
|
|
|
|
855
|
if ( ! -e $changes_file ) { |
|
|
100
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
$self->log_fatal("No $changes_file file found"); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ( $self->_get_changes ) { |
48
|
3
|
|
|
|
|
46
|
$self->log("$changes_file OK"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
2
|
|
|
|
|
33
|
$self->log_fatal("$changes_file has no content for $newver"); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
636
|
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
|
|
9
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# parse changelog to find commit message |
63
|
5
|
|
|
|
|
179
|
my $changelog = Dist::Zilla::File::OnDisk->new( { name => $self->changelog } ); |
64
|
5
|
|
|
|
|
1679
|
my $newver = $self->zilla->version; |
65
|
5
|
|
|
|
|
275
|
my $trial_token = $self->trial_token; |
66
|
|
|
|
|
|
|
my @content = |
67
|
5
|
|
|
|
|
39
|
grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented |
|
37
|
|
|
|
|
3673
|
|
68
|
|
|
|
|
|
|
split /\n/, $changelog->content; |
69
|
5
|
|
|
|
|
13
|
shift @content; # drop the version line |
70
|
|
|
|
|
|
|
# drop unindented last line and trailing blank lines |
71
|
5
|
|
100
|
|
|
70
|
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# return number of non-blank lines |
74
|
5
|
|
|
|
|
136
|
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.010 |
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 CONTRIBUTORS |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=for stopwords David Golden Randy Stauner |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over 4 |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
David Golden <xdg@xdg.me> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Randy Stauner <randy@magnificent-tears.com> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by David Golden. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This is free software, licensed under: |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |