line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- copyright and license --- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# file: lib/Dist/Zilla/Plugin/Author/VDB/Version/Bump.pm |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright © 2015 Van de Bugger |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This file is part of perl-Dist-Zilla-PluginBundle-Author-VDB. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# perl-Dist-Zilla-PluginBundle-Author-VDB is free software: you can redistribute it and/or modify |
10
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the Free Software |
11
|
|
|
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later version. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# perl-Dist-Zilla-PluginBundle-Author-VDB is distributed in the hope that it will be useful, but |
14
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
15
|
|
|
|
|
|
|
# PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along with |
18
|
|
|
|
|
|
|
# perl-Dist-Zilla-PluginBundle-Author-VDB. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- copyright and license --- |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#pod =for test_synopsis BEGIN { die "SKIP: not a Perl code"; } |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod F<dist.in> file: |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod ; version = v0.3.1 ; *Should **not** be used.* |
29
|
|
|
|
|
|
|
#pod ... |
30
|
|
|
|
|
|
|
#pod [Author::VDB::Version::Read] |
31
|
|
|
|
|
|
|
#pod file = VERSION |
32
|
|
|
|
|
|
|
#pod ... |
33
|
|
|
|
|
|
|
#pod [Author::VDB::Version::Bump] |
34
|
|
|
|
|
|
|
#pod file = VERSION |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod F<VERSION> file: |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod v0.3.1 |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod This plugin does C<AfterRelease> role. It bumps version in the specified file by incrementing alpha |
43
|
|
|
|
|
|
|
#pod component. For example, version C<v0.7.1> is bumped to C<v0.7.1_01>, then to C<v0.7.1_02>, etc. |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod =cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Author::VDB::Version::Bump; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
2
|
|
3329250
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
21
|
|
52
|
2
|
|
|
2
|
|
14639
|
use namespace::autoclean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
28
|
|
53
|
2
|
|
|
2
|
|
247
|
use version 0.77; |
|
2
|
|
|
|
|
96
|
|
|
2
|
|
|
|
|
18
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# ABSTRACT: Bump version after release |
56
|
|
|
|
|
|
|
our $VERSION = 'v0.11.2_05'; # TRIAL VERSION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterRelease'; |
59
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::ErrorLogger' => { -version => 'v0.9.0' }; |
60
|
|
|
|
|
|
|
# ^ We need `ErrorLogger` to throw an exception, not plain string. |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
2
|
|
234
|
use Path::Tiny; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
145
|
|
63
|
2
|
|
|
2
|
|
1959
|
use Perl::Version; |
|
2
|
|
|
|
|
6807
|
|
|
2
|
|
|
|
|
90
|
|
64
|
2
|
|
|
2
|
|
20
|
use Try::Tiny; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1098
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#pod =option file |
69
|
|
|
|
|
|
|
#pod |
70
|
|
|
|
|
|
|
#pod Name of file to bump version in. Default value is C<VERSION>. Specifying an empty file disables |
71
|
|
|
|
|
|
|
#pod the plugin. |
72
|
|
|
|
|
|
|
#pod |
73
|
|
|
|
|
|
|
#pod =cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'file' => ( |
76
|
|
|
|
|
|
|
isa => 'Str', |
77
|
|
|
|
|
|
|
is => 'ro', |
78
|
|
|
|
|
|
|
lazy => 1, |
79
|
|
|
|
|
|
|
default => 'VERSION', |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has _file => ( |
83
|
|
|
|
|
|
|
isa => 'Path::Tiny', |
84
|
|
|
|
|
|
|
is => 'ro', |
85
|
|
|
|
|
|
|
init_arg => undef, |
86
|
|
|
|
|
|
|
lazy => 1, |
87
|
|
|
|
|
|
|
default => sub { |
88
|
|
|
|
|
|
|
my ( $self ) = @_; |
89
|
|
|
|
|
|
|
my $path = path( $self->file ); |
90
|
|
|
|
|
|
|
if ( $path->is_absolute ) { |
91
|
|
|
|
|
|
|
$self->abort( [ "Bad version file '%s': absolute path is not allowed", $self->file ] ); |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
return $path->absolute( $self->zilla->root ); |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#pod =for Pod::Coverage after_release |
100
|
|
|
|
|
|
|
#pod |
101
|
|
|
|
|
|
|
#pod =cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub after_release { |
104
|
5
|
|
|
5
|
0
|
505663
|
my ( $self ) = @_; |
105
|
5
|
50
|
|
|
|
437
|
if ( $self->file ) { |
106
|
5
|
|
|
|
|
274
|
my $version = Perl::Version->new( $self->zilla->version ); |
107
|
5
|
|
|
|
|
1455
|
$version->inc_alpha(); |
108
|
|
|
|
|
|
|
try { |
109
|
5
|
|
|
5
|
|
726
|
$self->_file->append( { truncate => 1 }, "$version\n" ); |
110
|
|
|
|
|
|
|
# `append` is not atomic but keeps file mode intact. |
111
|
|
|
|
|
|
|
} catch { |
112
|
1
|
|
|
1
|
|
435
|
my $ex = $_; |
113
|
1
|
|
50
|
|
|
12
|
my $class = blessed( $ex ) || ''; |
114
|
1
|
50
|
|
|
|
9
|
if ( 0 ) { |
|
|
0
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
} elsif ( $class eq 'Dist::Zilla::Role::ErrorLogger::Exception::Abort' ) { |
116
|
|
|
|
|
|
|
# All the messages are aready logged, just rethrow the exception. |
117
|
1
|
|
|
|
|
21
|
die $ex; ## no critic ( RequireCarping ) |
118
|
|
|
|
|
|
|
} elsif ( blessed( $ex ) eq 'Try::Tiny::Error' ) { |
119
|
0
|
|
|
|
|
0
|
chomp( my $em = "$ex" ); |
120
|
0
|
|
|
|
|
0
|
$self->log_debug( $em ); |
121
|
0
|
|
|
|
|
0
|
$self->abort( [ "Can't write version file '%s': %s", $self->file, $ex->{ err } ] ); |
122
|
|
|
|
|
|
|
} else { |
123
|
0
|
|
|
|
|
0
|
$self->abort( $ex ); |
124
|
|
|
|
|
|
|
}; |
125
|
5
|
|
|
|
|
361
|
}; |
126
|
4
|
|
|
|
|
2381
|
$self->log_debug( [ 'next release version will be %s', "$version" ] ); |
127
|
|
|
|
|
|
|
} else { |
128
|
0
|
|
|
|
|
0
|
$self->log_debug( 'no version file specified' ); |
129
|
|
|
|
|
|
|
}; |
130
|
4
|
|
|
|
|
880
|
return; |
131
|
|
|
|
|
|
|
}; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#pod =head1 COPYRIGHT AND LICENSE |
140
|
|
|
|
|
|
|
#pod |
141
|
|
|
|
|
|
|
#pod Copyright (C) 2015 Van de Bugger |
142
|
|
|
|
|
|
|
#pod |
143
|
|
|
|
|
|
|
#pod License GPLv3+: The GNU General Public License version 3 or later |
144
|
|
|
|
|
|
|
#pod <http://www.gnu.org/licenses/gpl-3.0.txt>. |
145
|
|
|
|
|
|
|
#pod |
146
|
|
|
|
|
|
|
#pod This is free software: you are free to change and redistribute it. There is |
147
|
|
|
|
|
|
|
#pod NO WARRANTY, to the extent permitted by law. |
148
|
|
|
|
|
|
|
#pod |
149
|
|
|
|
|
|
|
#pod |
150
|
|
|
|
|
|
|
#pod =cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# end of file # |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=pod |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=encoding UTF-8 |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 NAME |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Author::VDB::Version::Bump - Bump version after release |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 VERSION |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Version v0.11.2_05, released on 2016-12-08 00:45 UTC. |
167
|
|
|
|
|
|
|
This is a B<trial release>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=for test_synopsis BEGIN { die "SKIP: not a Perl code"; } |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SYNOPSIS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
F<dist.in> file: |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
; version = v0.3.1 ; *Should **not** be used.* |
176
|
|
|
|
|
|
|
... |
177
|
|
|
|
|
|
|
[Author::VDB::Version::Read] |
178
|
|
|
|
|
|
|
file = VERSION |
179
|
|
|
|
|
|
|
... |
180
|
|
|
|
|
|
|
[Author::VDB::Version::Bump] |
181
|
|
|
|
|
|
|
file = VERSION |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
F<VERSION> file: |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
v0.3.1 |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 DESCRIPTION |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This plugin does C<AfterRelease> role. It bumps version in the specified file by incrementing alpha |
190
|
|
|
|
|
|
|
component. For example, version C<v0.7.1> is bumped to C<v0.7.1_01>, then to C<v0.7.1_02>, etc. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 OPTIONS |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 file |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Name of file to bump version in. Default value is C<VERSION>. Specifying an empty file disables |
197
|
|
|
|
|
|
|
the plugin. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=for Pod::Coverage after_release |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Van de Bugger <van.de.bugger@gmail.com> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Copyright (C) 2015 Van de Bugger |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
License GPLv3+: The GNU General Public License version 3 or later |
210
|
|
|
|
|
|
|
<http://www.gnu.org/licenses/gpl-3.0.txt>. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This is free software: you are free to change and redistribute it. There is |
213
|
|
|
|
|
|
|
NO WARRANTY, to the extent permitted by law. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |