line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitHooks::Plugin::Test::CustomReply; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
98777
|
use strict; |
|
22
|
|
|
|
|
32
|
|
|
22
|
|
|
|
|
616
|
|
4
|
22
|
|
|
22
|
|
84
|
use warnings; |
|
22
|
|
|
|
|
29
|
|
|
22
|
|
|
|
|
617
|
|
5
|
|
|
|
|
|
|
|
6
|
22
|
|
|
22
|
|
85
|
use base 'App::GitHooks::Plugin'; |
|
22
|
|
|
|
|
33
|
|
|
22
|
|
|
|
|
2820
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# External dependencies. |
9
|
22
|
|
|
22
|
|
95
|
use Carp; |
|
22
|
|
|
|
|
31
|
|
|
22
|
|
|
|
|
1308
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Internal dependencies. |
12
|
22
|
|
|
22
|
|
1394
|
use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES ); |
|
22
|
|
|
|
|
30
|
|
|
22
|
|
|
|
|
4915
|
|
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.9.0 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = '1.9.0'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
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
|
|
|
15
|
1
|
5006
|
return qr//x; |
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
|
|
|
15
|
1
|
5115
|
return 'Test plugin - custom return codes.'; |
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
|
|
|
|
|
|
|
foreach my $hook ( @$App::GitHooks::Plugin::SUPPORTED_SUBS ) |
129
|
|
|
|
|
|
|
{ |
130
|
22
|
|
|
22
|
|
118
|
no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) |
|
22
|
|
|
|
|
36
|
|
|
22
|
|
|
|
|
4906
|
|
131
|
|
|
|
|
|
|
my $sub = 'run_' . $hook; |
132
|
|
|
|
|
|
|
*$sub = sub |
133
|
|
|
|
|
|
|
{ |
134
|
21
|
|
|
21
|
|
379
|
my ( $class, %args ) = @_; |
135
|
21
|
|
|
|
|
63
|
my $app = delete( $args{'app'} ); |
136
|
21
|
|
|
|
|
240
|
my $config = $app->get_config(); |
137
|
|
|
|
|
|
|
|
138
|
21
|
|
50
|
|
|
128
|
my $return = $config->get( 'Test::CustomReply', $hook ) // ''; |
139
|
21
|
50
|
|
|
|
369
|
croak "No return value specified for >$hook<." |
140
|
|
|
|
|
|
|
if $return !~ /\w/; |
141
|
21
|
50
|
|
|
|
151
|
croak "The return value for >$hook< in the [Test::CustomReply] section of the .githooksrc is not valid." |
142
|
|
|
|
|
|
|
if $return !~ /^PLUGIN_RETURN_(?:FAILED|PASSED|WARNED|SKIPPED)$/x; |
143
|
|
|
|
|
|
|
|
144
|
21
|
|
|
|
|
27
|
return ${$return}; |
|
21
|
|
|
|
|
167
|
|
145
|
|
|
|
|
|
|
}; |
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-2017 Guillaume Aubert. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This code is free software; you can redistribute it and/or modify it under the |
198
|
|
|
|
|
|
|
same terms as Perl 5 itself. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
201
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
202
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the LICENSE file for more details. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |