File Coverage

blib/lib/Dist/Zilla/Plugin/Author/VDB/Hg/Commit.pm
Criterion Covered Total %
statement 17 25 68.0
branch 1 4 25.0
condition n/a
subroutine 7 8 87.5
pod 0 4 0.0
total 25 41 60.9


line stmt bran cond sub pod time code
1             # ---------------------------------------------------------------------- copyright and license ---
2             #
3             # file: lib/Dist/Zilla/Plugin/Author/VDB/Hg/Commit.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::Commit]
29             #pod file = .hgtags
30             #pod file = remote
31             #pod ...
32             #pod
33             #pod =head1 DESCRIPTION
34             #pod
35             #pod This plugin does C<AfterRelease> role. It commits specified files to the Mercurial repository.
36             #pod
37             #pod =cut
38              
39             # --------------------------------------------------------------------------------------------------
40              
41             package Dist::Zilla::Plugin::Author::VDB::Hg::Commit;
42              
43 1     1   2297 use Moose;
  1         1  
  1         22  
44 1     1   11038 use namespace::autoclean;
  1         3  
  1         18  
45 1     1   142 use version 0.77;
  1         45  
  1         14  
46              
47             # ABSTRACT: Commit files to repository
48             our $VERSION = 'v0.11.2_04'; # TRIAL VERSION
49              
50 1     1   158 use Path::Tiny qw{ tempfile };
  1         3  
  1         822  
51              
52             with 'Dist::Zilla::Role::AfterRelease';
53             with 'Dist::Zilla::Role::ErrorLogger';
54             with 'Dist::Zilla::Role::Author::VDB::HgRunner';
55              
56             # --------------------------------------------------------------------------------------------------
57              
58             #pod =option message
59             #pod
60             #pod Commit message.
61             #pod
62             #pod =cut
63              
64             has message => (
65             isa => 'Str',
66             is => 'ro',
67             default => 'post-release',
68             );
69              
70             # --------------------------------------------------------------------------------------------------
71              
72             #pod =option file
73             #pod
74             #pod =option files
75             #pod
76             #pod File name to commit. May be repeated multiple times to push changes to commit several files.
77             #pod
78             #pod =cut
79              
80             has files => (
81             isa => 'ArrayRef[Str]',
82             is => 'ro',
83             default => sub { [] },
84             );
85              
86             # --------------------------------------------------------------------------------------------------
87              
88             #pod =for Pod::Coverage mvp_aliases mvp_multivalue_args
89             #pod
90             #pod =cut
91              
92             sub mvp_aliases {
93             return {
94 7     7 0 1150 'file' => 'files',
95             };
96             };
97              
98             sub mvp_multivalue_args {
99 7     7 0 6524 return qw{ files };
100             };
101              
102             # --------------------------------------------------------------------------------------------------
103              
104             #pod =for Pod::Coverage BUILD
105             #pod
106             #pod =cut
107              
108             sub BUILD {
109 7     7 0 12 my ( $self ) = @_;
110 7 50       362 if ( $self->message eq '' ) {
111 0         0 $self->abort( 'message option must not be empty' );
112             };
113 7         320 return;
114             };
115              
116             # --------------------------------------------------------------------------------------------------
117              
118             #pod =for Pod::Coverage after_release
119             #pod
120             #pod =cut
121              
122             sub after_release {
123 0     0 0   my ( $self ) = @_;
124 0           my @files = grep( { $_ ne '' } @{ $self->files } );
  0            
  0            
125 0 0         if ( @files ) {
126 0           $self->run_hg( 'commit', '-m', $self->message, @files );
127             };
128 0           return;
129             };
130              
131             # --------------------------------------------------------------------------------------------------
132              
133             __PACKAGE__->meta->make_immutable();
134              
135             1;
136              
137             # --------------------------------------------------------------------------------------------------
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::Hg::Commit - Commit files to repository
163              
164             =head1 VERSION
165              
166             Version v0.11.2_04, released on 2016-12-06 20:27 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             [Author::VDB::Hg::Commit]
176             file = .hgtags
177             file = remote
178             ...
179              
180             =head1 DESCRIPTION
181              
182             This plugin does C<AfterRelease> role. It commits specified files to the Mercurial repository.
183              
184             =head1 OPTIONS
185              
186             =head2 message
187              
188             Commit message.
189              
190             =head2 file
191              
192             =head2 files
193              
194             File name to commit. May be repeated multiple times to push changes to commit several files.
195              
196             =for Pod::Coverage mvp_aliases mvp_multivalue_args
197              
198             =for Pod::Coverage BUILD
199              
200             =for Pod::Coverage after_release
201              
202             =head1 AUTHOR
203              
204             Van de Bugger <van.de.bugger@gmail.com>
205              
206             =head1 COPYRIGHT AND LICENSE
207              
208             Copyright (C) 2015 Van de Bugger
209              
210             License GPLv3+: The GNU General Public License version 3 or later
211             <http://www.gnu.org/licenses/gpl-3.0.txt>.
212              
213             This is free software: you are free to change and redistribute it. There is
214             NO WARRANTY, to the extent permitted by law.
215              
216             =cut