| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::GitHooks::Plugin::RequireTicketID; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
704188
|
use strict; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
110
|
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
90
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use base 'App::GitHooks::Plugin'; |
|
|
3
|
|
|
|
|
10
|
|
|
|
3
|
|
|
|
|
1156
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Internal dependencies. |
|
9
|
3
|
|
|
3
|
|
1387
|
use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES ); |
|
|
3
|
|
|
|
|
305
|
|
|
|
3
|
|
|
|
|
1058
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
App::GitHooks::Plugin::RequireTicketID - Require a ticket ID in the commit message. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
If you are using a ticketing system, it is very useful to make sure that all |
|
20
|
|
|
|
|
|
|
your commit messages include a ticket ID to provide more context into why the |
|
21
|
|
|
|
|
|
|
code is being changed. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Version 1.0.3 |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 run_commit_msg() |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Code to execute as part of the commit-msg hook. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $success = App::GitHooks::Plugin::RequireTicketID->run_commit_msg(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run_commit_msg |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
2
|
|
|
2
|
1
|
13968
|
my ( $class, %args ) = @_; |
|
46
|
2
|
|
|
|
|
9
|
my $commit_message = delete( $args{'commit_message'} ); |
|
47
|
2
|
|
|
|
|
6
|
my $app = delete( $args{'app'} ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# We must have a ticket ID. |
|
50
|
2
|
|
|
|
|
15
|
my $ticket_id = $commit_message->get_ticket_id(); |
|
51
|
2
|
100
|
|
|
|
303
|
if ( !defined( $ticket_id ) ) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
1
|
|
|
|
|
7
|
my $failure_character = $app->get_failure_character(); |
|
54
|
1
|
|
|
|
|
25
|
my $indent = ' '; |
|
55
|
1
|
|
|
|
|
8
|
print $app->color( 'red', $failure_character . " Your commit message needs to start with a ticket ID.\n" ); |
|
56
|
1
|
|
|
|
|
32
|
return $PLUGIN_RETURN_FAILED; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
4
|
return $PLUGIN_RETURN_PASSED; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 BUGS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
|
66
|
|
|
|
|
|
|
L. |
|
67
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
68
|
|
|
|
|
|
|
your bug as I make changes. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SUPPORT |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
perldoc App::GitHooks::Plugin::RequireTicketID |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
You can also look for information at: |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * GitHub's request tracker |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * MetaCPAN |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L, |
|
104
|
|
|
|
|
|
|
C<< >>. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright 2013-2014 Guillaume Aubert. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
|
112
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
|
113
|
|
|
|
|
|
|
Software Foundation. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
|
116
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
117
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
120
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |