blib/lib/App/GitHooks/Plugin/Test/CustomReply.pm

filter: Statementstmt 100% 34 / 34 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 92.3% 48 / 52 CC 4 SCAR 7.2
CC
4
Cov
92%
__ANON__
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« blib/lib/App/GitHooks/Hook.pm ↑ Summary blib/lib/App/GitHooks/Hook/ApplypatchMsg.pm »
1 package App::GitHooks::Plugin::Test::CustomReply;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 22 ▶use base 'App::GitHooks::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # External dependencies.
9 22 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Internal dependencies.
12 22 ▶use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 =head1 NAME
16  
17 App::GitHooks::Plugin::Test::CustomReply - A test plugin that allows specifying the return code.
18  
19  
20 =head1 DESCRIPTION
21  
22  
23 =head1 SYNOPSIS
24  
25 use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES );
26 use App::GitHooks::Plugin::Test::CustomReply;
27  
28 # In .githooksrc.
29 # [Test::CustomReply]
30 # pre-commit = PLUGIN_RETURN_FAILED
31 # prepare-commit-msg = PLUGIN_RETURN_PASSED
32  
33 # Run hooks calling the plugin.
34  
35  
36 =head1 VERSION
37  
38 Version 1.7.3
39  
40 =cut
41  
42 22 our $VERSION = '1.7.3';
43  
44 22 our $HOOK_REPLIES;
45  
46  
47 =head1 METHODS
48  
49 =head2 get_file_pattern()
50  
51 Return a pattern to filter the files this plugin should analyze.
52  
53 my $file_pattern = App::GitHooks::Plugin::Test::CustomReply->get_file_pattern(
54 app => $app,
55 );
56  
57 =cut
58  
59 sub get_file_pattern
60 {
61 15 ▶ return qr//x;
Subroutine get_file_pattern: called CC=1 SCAR=0.0
Pod documented
62 }
63  
64  
65 =head2 get_file_check_description()
66  
67 Return a description of the check performed on files by the plugin and that
68 will be displayed to the user, if applicable, along with an indication of the
69 success or failure of the plugin.
70  
71 my $description = App::GitHooks::Plugin::Test::CustomReply->get_file_check_description();
72  
73 =cut
74  
75 sub get_file_check_description
76 {
77 15 ▶ return 'Test plugin - custom return codes.';
Subroutine get_file_check_description: called CC=1 SCAR=0.0
Pod documented
78 }
79  
80  
81 =head1 SUPPORTED HOOKS
82  
83 This plugin supports all the hooks defined in C<App::GitHooks::Hook::*>,
84 including file-level checks for the appropriate hooks:
85  
86 =over 4
87  
88 =item run_applypatch_msg
89  
90 =item run_commit_msg
91  
92 =item run_post_applypatch
93  
94 =item run_post_checkout
95  
96 =item run_post_commit
97  
98 =item run_post_merge
99  
100 =item run_post_receive
101  
102 =item run_post_rewrite
103  
104 =item run_post_update
105  
106 =item run_pre_applypatch
107  
108 =item run_pre_auto_gc
109  
110 =item run_pre_commit
111  
112 =item run_pre_commit_file
113  
114 =item run_pre_push
115  
116 =item run_pre_rebase
117  
118 =item run_pre_receive
119  
120 =item run_prepare_commit_msg
121  
122 =item run_update
123  
124 =back
125  
126 =cut
127  
128 22 foreach my $hook ( @$App::GitHooks::Plugin::SUPPORTED_SUBS )
129 {
130 22 ▶ no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
Subroutine BEGIN: called CC=1 SCAR=0.0
131 396 my $sub = 'run_' . $hook;
132 *$sub = sub
133 {
134 21 ▶ my ( $class, %args ) = @_;
Subroutine __ANON__: called CC=4 SCAR=14.2
135 21 my $app = delete( $args{'app'} );
136 21 my $config = $app->get_config();
137  
138 21 ▶ my $return = $config->get( 'Test::CustomReply', $hook ) // '';
Condition50%1/2
$config->get("Test::CustomReply", $hook) // ""
l!l
210
MC/DC0%0/1
$config->get("Test::CustomReply", $hook) // ""
$config->get("Test::CustomReply", $hook)
Truth table50%1/2
A
A= $config->get("Test::CustomReply", $hook)
Aresult
11
00
139 21 ▶ croak "No return value specified for >$hook<."
Branch: 1 branch
BranchTrueFalseTotal
unless $return =~ /\w/ 0 21 21
140 if $return !~ /\w/;
141 21 ▶ croak "The return value for >$hook< in the [Test::CustomReply] section of the .githooksrc is not valid."
Branch: 1 branch
BranchTrueFalseTotal
unless $return =~ /^PLUGIN_RETURN_(?:FAILED|PASSED|WARNED|SKIPPED)$/x 0 21 21
142 if $return !~ /^PLUGIN_RETURN_(?:FAILED|PASSED|WARNED|SKIPPED)$/x;
143  
144 21 return ${$return};
145 396 };
146 }
147  
148  
149 =head1 BUGS
150  
151 Please report any bugs or feature requests through the web interface at
152 L<https://github.com/guillaumeaubert/App-GitHooks/issues/new>.
153 I will be notified, and then you'll automatically be notified of progress on
154 your bug as I make changes.
155  
156  
157 =head1 SUPPORT
158  
159 You can find documentation for this module with the perldoc command.
160  
161 perldoc App::GitHooks::Plugin::Test::CustomReply
162  
163  
164 You can also look for information at:
165  
166 =over
167  
168 =item * GitHub's request tracker
169  
170 L<https://github.com/guillaumeaubert/App-GitHooks/issues>
171  
172 =item * AnnoCPAN: Annotated CPAN documentation
173  
174 L<http://annocpan.org/dist/app-githooks>
175  
176 =item * CPAN Ratings
177  
178 L<http://cpanratings.perl.org/d/app-githooks>
179  
180 =item * MetaCPAN
181  
182 L<https://metacpan.org/release/App-GitHooks>
183  
184 =back
185  
186  
187 =head1 AUTHOR
188  
189 L<Guillaume Aubert|https://metacpan.org/author/AUBERTG>,
190 C<< <aubertg at cpan.org> >>.
191  
192  
193 =head1 COPYRIGHT & LICENSE
194  
195 Copyright 2013-2015 Guillaume Aubert.
196  
197 This program is free software: you can redistribute it and/or modify it under
198 the terms of the GNU General Public License version 3 as published by the Free
199 Software Foundation.
200  
201 This program is distributed in the hope that it will be useful, but WITHOUT ANY
202 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
203 PARTICULAR PURPOSE. See the GNU General Public License for more details.
204  
205 You should have received a copy of the GNU General Public License along with
206 this program. If not, see http://www.gnu.org/licenses/
207  
208 =cut
209  
210 22 1;
« blib/lib/App/GitHooks/Hook.pm ↑ Summary blib/lib/App/GitHooks/Hook/ApplypatchMsg.pm »