line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- copyright and license --- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# file: lib/Dist/Zilla/Plugin/Author/VDB/Hg/Tag/Add.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 [Author::VDB::Hg::Tag::Add] |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod This plugin does C<AfterRelease> role. It tags current version in Mercurial repository (but does |
33
|
|
|
|
|
|
|
#pod not commit the change!). |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod =cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Author::VDB::Hg::Tag::Add; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
163562
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
42
|
1
|
|
|
1
|
|
5276
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
43
|
1
|
|
|
1
|
|
76
|
use version 0.77; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
8
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# ABSTRACT: Add tag (but don't commit it) [after release] |
46
|
|
|
|
|
|
|
our $VERSION = 'v0.11.2_06'; # TRIAL VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::AfterRelease'; |
49
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::ErrorLogger'; |
50
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Author::VDB::HgRunner'; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
104
|
use Path::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
517
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#pod =option local |
57
|
|
|
|
|
|
|
#pod |
58
|
|
|
|
|
|
|
#pod If 1, local tag will be added. |
59
|
|
|
|
|
|
|
#pod |
60
|
|
|
|
|
|
|
#pod =cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has local => ( |
63
|
|
|
|
|
|
|
isa => 'Bool', |
64
|
|
|
|
|
|
|
is => 'ro', |
65
|
|
|
|
|
|
|
default => 0, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#pod =for Pod::Coverage after_release |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod =cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub after_release { |
75
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
76
|
0
|
|
|
|
|
|
my $root = path( $self->zilla->root ); |
77
|
0
|
|
|
|
|
|
my $identify = $self->run_hg( 'identify', '--id', '--debug' ); |
78
|
0
|
0
|
0
|
|
|
|
if ( @$identify != 1 or $identify->[ 0 ] !~ m{ ^ ([0-9a-f]{40}) (\+?) $ }x ) { |
79
|
0
|
|
|
|
|
|
$self->log_error( "Can't parse 'hg identify' output:" ); |
80
|
0
|
|
|
|
|
|
$self->log_error( " $_" ) for @$identify; |
81
|
0
|
|
|
|
|
|
$self->abort(); |
82
|
|
|
|
|
|
|
}; |
83
|
0
|
|
|
|
|
|
my ( $id, $dirty ) = ( $1, $2 ); ## no critic ( ProhibitCaptureWithoutTest ) |
84
|
0
|
0
|
|
|
|
|
if ( $dirty ) { |
85
|
0
|
|
|
|
|
|
$self->abort( "The working directory has uncommitted changes" ); |
86
|
|
|
|
|
|
|
}; |
87
|
0
|
0
|
|
|
|
|
if ( $id eq '0' x 40 ) { |
88
|
0
|
|
|
|
|
|
$self->abort( "Oops, current changeset has null id" ); |
89
|
|
|
|
|
|
|
# ^ TODO: More user-friendly error message |
90
|
|
|
|
|
|
|
}; |
91
|
0
|
0
|
|
|
|
|
my $tags = $root->child( $self->local ? '.hg/localtags' : '.hgtags' ); |
92
|
0
|
0
|
|
|
|
|
$self->log_debug( [ |
93
|
|
|
|
|
|
|
$self->local ? "adding local tag %s" : "adding tag %s", |
94
|
|
|
|
|
|
|
$self->zilla->version |
95
|
|
|
|
|
|
|
] ); |
96
|
0
|
|
|
|
|
|
$tags->append( sprintf( "%s %s\n", $id, $self->zilla->version ) ); |
97
|
0
|
0
|
|
|
|
|
if ( not $self->local ) { |
98
|
|
|
|
|
|
|
# Make sure `.hgtags` file is added to repository. |
99
|
0
|
|
|
|
|
|
my $status = $self->run_hg( 'status', '.hgtags' ); |
100
|
0
|
0
|
0
|
|
|
|
if ( @$status != 1 or $status->[ 0 ] !~ m{ ^ ([?M]) \s \.hgtags $ }x ) { |
101
|
0
|
|
|
|
|
|
$self->log_error( "Unexpected 'hg status' output:" ); |
102
|
0
|
|
|
|
|
|
$self->log_error( [ " $_" ] ) for @$status; |
103
|
0
|
|
|
|
|
|
$self->abort(); |
104
|
|
|
|
|
|
|
}; |
105
|
0
|
|
|
|
|
|
my $mark = $1; ## no critic ( ProhibitCaptureWithoutTest ) |
106
|
0
|
0
|
|
|
|
|
if ( $mark eq '?' ) { |
107
|
0
|
|
|
|
|
|
$self->run_hg( 'add', '.hgtags' ); |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
}; |
110
|
0
|
|
|
|
|
|
return; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#pod =head1 COPYRIGHT AND LICENSE |
122
|
|
|
|
|
|
|
#pod |
123
|
|
|
|
|
|
|
#pod Copyright (C) 2015 Van de Bugger |
124
|
|
|
|
|
|
|
#pod |
125
|
|
|
|
|
|
|
#pod License GPLv3+: The GNU General Public License version 3 or later |
126
|
|
|
|
|
|
|
#pod <http://www.gnu.org/licenses/gpl-3.0.txt>. |
127
|
|
|
|
|
|
|
#pod |
128
|
|
|
|
|
|
|
#pod This is free software: you are free to change and redistribute it. There is |
129
|
|
|
|
|
|
|
#pod NO WARRANTY, to the extent permitted by law. |
130
|
|
|
|
|
|
|
#pod |
131
|
|
|
|
|
|
|
#pod |
132
|
|
|
|
|
|
|
#pod =cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# end of file # |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=pod |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=encoding UTF-8 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 NAME |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Author::VDB::Hg::Tag::Add - Add tag (but don't commit it) [after release] |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 VERSION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Version v0.11.2_06, released on 2016-12-15 22:13 UTC. |
149
|
|
|
|
|
|
|
This is a B<trial release>. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=for test_synopsis BEGIN { die "SKIP: not a Perl code"; } |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
F<dist.in> file: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
[Author::VDB::Hg::Tag::Add] |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 DESCRIPTION |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This plugin does C<AfterRelease> role. It tags current version in Mercurial repository (but does |
162
|
|
|
|
|
|
|
not commit the change!). |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 OPTIONS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 local |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
If 1, local tag will be added. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=for Pod::Coverage after_release |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 AUTHOR |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Van de Bugger <van.de.bugger@gmail.com> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Copyright (C) 2015 Van de Bugger |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
License GPLv3+: The GNU General Public License version 3 or later |
181
|
|
|
|
|
|
|
<http://www.gnu.org/licenses/gpl-3.0.txt>. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This is free software: you are free to change and redistribute it. There is |
184
|
|
|
|
|
|
|
NO WARRANTY, to the extent permitted by law. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |