line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::CheckChangeLog; |
2
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::CheckChangeLog::VERSION = '0.05'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Dist::Zilla with Changes check |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2646200
|
use 5.004; |
|
2
|
|
|
|
|
6
|
|
6
|
2
|
|
|
2
|
|
319
|
use Moose; |
|
2
|
|
|
|
|
364599
|
|
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterBuild'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has filename => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'Str' |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub after_build { |
16
|
4
|
|
|
4
|
1
|
108675
|
my ($self, $args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
10
|
my $root = $args->{build_root}; |
19
|
4
|
|
|
|
|
23
|
my $filename = $self->{filename}; |
20
|
4
|
|
|
|
|
6
|
my @change_files; |
21
|
|
|
|
|
|
|
|
22
|
4
|
100
|
|
|
|
13
|
if ($filename) { |
23
|
2
|
|
|
|
|
5
|
chomp($filename); |
24
|
2
|
50
|
|
|
|
22
|
die "[CheckChangeLog] $! $filename\n" unless -e $filename; |
25
|
2
|
|
|
|
|
62
|
push @change_files, Dist::Zilla::File::OnDisk->new({name => $filename}); |
26
|
|
|
|
|
|
|
} else { |
27
|
|
|
|
|
|
|
# Search for Changes or ChangeLog on build root |
28
|
2
|
|
|
|
|
6
|
my @files = $self->_find_change_files($root); |
29
|
2
|
50
|
|
|
|
33
|
die "[CheckChangeLog] No changelog file found.\n" unless scalar @files; |
30
|
2
|
|
|
|
|
5
|
push @change_files, @files; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
516
|
for my $file (@change_files) { |
34
|
4
|
100
|
|
|
|
15
|
if ($self->has_version($file->content, $self->zilla->version)) { |
35
|
2
|
|
|
|
|
9
|
$self->log("[CheckChangeLog] OK with " . $file->name); |
36
|
2
|
|
|
|
|
748
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
4
|
my $msg = "[CheckChangeLog] No Change Log in "; |
41
|
2
|
|
|
|
|
5
|
$msg .= join(', ', map { $_->name } @change_files) . "\n"; |
|
2
|
|
|
|
|
6
|
|
42
|
2
|
|
|
|
|
95
|
$self->log($msg); |
43
|
2
|
|
|
|
|
678
|
$msg = "[CheckChangeLog] Update your Changes file with an entry for "; |
44
|
2
|
|
|
|
|
52
|
$msg .= $self->zilla->version . "\n"; |
45
|
2
|
|
|
|
|
86
|
die $msg; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub has_version { |
49
|
4
|
|
|
4
|
1
|
2386
|
my ($self, $content, $version) = @_; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
15
|
for my $line (split(/\n/, $content)) { |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# no blank lines |
54
|
3
|
50
|
|
|
|
37
|
next unless $line =~ /\S/; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# skip things that look like bullets |
57
|
3
|
50
|
|
|
|
12
|
next if $line =~ /^\s+/; |
58
|
3
|
50
|
|
|
|
19
|
next if $line =~ /^\*/; |
59
|
3
|
50
|
|
|
|
7
|
next if $line =~ /^\-/; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# seen it? |
62
|
3
|
100
|
|
|
|
28
|
return 1 if $line =~ /\Q$version\E/; |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
8
|
return 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _find_change_files { |
68
|
2
|
|
|
2
|
|
3
|
my ($self, $root) = @_; |
69
|
2
|
|
|
|
|
54
|
my $files = $self->zilla->files; |
70
|
2
|
|
|
|
|
58
|
my $change_file_re = qr/Change(?:s|Log)?/i; |
71
|
2
|
50
|
|
8
|
|
10
|
my $filter = sub { -e "$root/$_->{name}" && $_->{name} =~ $change_file_re }; |
|
8
|
|
|
|
|
19
|
|
72
|
2
|
|
|
|
|
15
|
grep { $filter->($_) } @{$files}; |
|
8
|
|
|
|
|
100
|
|
|
2
|
|
|
|
|
5
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
76
|
2
|
|
|
2
|
|
12582
|
no Moose; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
8
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Dist::Zilla::Plugin::CheckChangeLog - Dist::Zilla with Changes check |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.05 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# dist.ini |
97
|
|
|
|
|
|
|
[CheckChangeLog] |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# or |
100
|
|
|
|
|
|
|
[CheckChangeLog] |
101
|
|
|
|
|
|
|
filename = Changes.pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DESCRIPTION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This plugin will examine your changes file after a build to make sure it has an entry for your distributions current version prior to a release. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 File name conventions |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
With no arguments CheckChangeLog will only look in files named Changes and ChangeLog (case insensitive) within the root directory of your dist. Note you can always pass a filename argument if you have an unconvential name and place for your changelog. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 after_build |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 has_version($content_str, $version_str) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHORS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Fayland Lam, C<< <fayland at gmail.com> >> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Fayland Lam <fayland@gmail.com> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Fayland Lam. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
130
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |