line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Repository::Plugin::Blame::Line; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
18129
|
use warnings; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
235
|
|
4
|
8
|
|
|
8
|
|
36
|
use strict; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
211
|
|
5
|
8
|
|
|
8
|
|
139
|
use 5.006; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
229
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
32
|
use Carp; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
3768
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Git::Repository::Plugin::Blame::Line - Store the git blame information for a line of code. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 1.2.3 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '1.2.3'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Git::Repository::Plugin::Blame::Line; |
27
|
|
|
|
|
|
|
my $line = Git::Repository::Plugin::Blame::Line->new( |
28
|
|
|
|
|
|
|
line_number => $line_number, |
29
|
|
|
|
|
|
|
line => $line, |
30
|
|
|
|
|
|
|
commit_attributes => \%commit_attributes, |
31
|
|
|
|
|
|
|
commit_id => $commit_id, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
print "The line number is " . $line->get_line_number() . "\n"; |
35
|
|
|
|
|
|
|
print "The line is " . $line->get_line() . "\n"; |
36
|
|
|
|
|
|
|
print "The commit ID is " . $line->get_commit_id() . "\n"; |
37
|
|
|
|
|
|
|
print "The commit attributes are: \n"; |
38
|
|
|
|
|
|
|
while ( my ( $name, $value ) = each( %{ $line->get_commit_attributes() } ) ) |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
print " - $name: $value\n"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This module stores the git blame information for a line of code. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Create a new Git::Repository::Plugin::Blame::Line object. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $line = Git::Repository::Plugin::Blame::Line->new( |
56
|
|
|
|
|
|
|
line_number => $line_number, |
57
|
|
|
|
|
|
|
line => $line, |
58
|
|
|
|
|
|
|
commit_attributes => \%commit_attributes, |
59
|
|
|
|
|
|
|
commit_id => $commit_id, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
All parameters are mandatory: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * 'line_number' |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The number of this line in the file that git blame was applied to. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * 'line' |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The text/code of this line in the file that git blame was applied to. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * 'commit_attributes' |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
A hashref of attributes for the last commit that modified this line. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * 'commit_id' |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The ID of the last commit that modified this line. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new |
87
|
|
|
|
|
|
|
{ |
88
|
19
|
|
|
19
|
1
|
3538
|
my ( $class, %args ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Verify parameters. |
91
|
19
|
|
|
|
|
36
|
foreach my $arg ( qw( line_number commit_id ) ) |
92
|
|
|
|
|
|
|
{ |
93
|
37
|
100
|
66
|
|
|
223
|
croak "The argument '$arg' must be defined to create a Git::Repository::Plugin::Blame::Line object" |
94
|
|
|
|
|
|
|
if !defined( $args{$arg} ) || ( $args{$arg} eq '' ); |
95
|
|
|
|
|
|
|
} |
96
|
17
|
100
|
|
|
|
63
|
croak "The argument 'line' must be defined to create a Git::Repository::Plugin::Blame::Line object" |
97
|
|
|
|
|
|
|
if !defined( $args{'line'} ); |
98
|
|
|
|
|
|
|
|
99
|
16
|
100
|
|
|
|
93
|
croak "The argument 'line_number' must be a strictly positive integer" |
100
|
|
|
|
|
|
|
if $args{'line_number'} !~ /^\d+$/; |
101
|
|
|
|
|
|
|
|
102
|
15
|
|
|
|
|
22
|
my $commit_attributes = $args{'commit_attributes'}; |
103
|
15
|
100
|
66
|
|
|
86
|
croak "The argument 'commit_attributes' must be a hashref to create a Git::Repository::Plugin::Blame::Line object" |
104
|
|
|
|
|
|
|
if !defined( $commit_attributes ) || ( ref( $commit_attributes ) ne 'HASH' ); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Clean emails in commit attributes. |
107
|
14
|
|
|
|
|
60
|
foreach my $name ( keys %$commit_attributes ) |
108
|
|
|
|
|
|
|
{ |
109
|
89
|
100
|
|
|
|
187
|
next unless $name =~ /^(?:author|committer)-mail$/x; |
110
|
17
|
|
|
|
|
40
|
$commit_attributes->{ $name } =~ s/^/; |
111
|
17
|
|
|
|
|
37
|
$commit_attributes->{ $name } =~ s/>$//; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Create and return the object. |
115
|
14
|
|
|
|
|
141
|
return bless( |
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
line_number => $args{'line_number'}, |
118
|
|
|
|
|
|
|
line => $args{'line'}, |
119
|
|
|
|
|
|
|
commit_attributes => $args{'commit_attributes'}, |
120
|
|
|
|
|
|
|
commit_id => $args{'commit_id'}, |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
$class |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 get_line_number() |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Return the number of this line in the file that git blame was applied to. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $line_number = $line->get_line_number(); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub get_line_number |
136
|
|
|
|
|
|
|
{ |
137
|
5
|
|
|
5
|
1
|
5318
|
my ( $self ) = @_; |
138
|
|
|
|
|
|
|
|
139
|
5
|
|
|
|
|
27
|
return $self->{'line_number'}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 get_line() |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Return the text/code of this line in the file that git blame was applied to. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $line = $line->get_line(); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub get_line |
152
|
|
|
|
|
|
|
{ |
153
|
1
|
|
|
1
|
1
|
1169
|
my ( $self ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
10
|
return $self->{'line'}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 get_commit_id() |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Return the SHA-1 of the last commit that modified this line. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $commit_id = $line->get_commit_id(); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub get_commit_id |
168
|
|
|
|
|
|
|
{ |
169
|
5
|
|
|
5
|
1
|
2137
|
my ( $self ) = @_; |
170
|
|
|
|
|
|
|
|
171
|
5
|
|
|
|
|
25
|
return $self->{'commit_id'}; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 get_commit_attributes() |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Return the hashref of attributes for the last commit that modified this line. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $commit_attributes = $line->get_commit_attributes(); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub get_commit_attributes |
184
|
|
|
|
|
|
|
{ |
185
|
5
|
|
|
5
|
1
|
673
|
my ( $self ) = @_; |
186
|
|
|
|
|
|
|
|
187
|
5
|
|
|
|
|
16
|
return $self->{'commit_attributes'}; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 BUGS |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
194
|
|
|
|
|
|
|
L. |
195
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
196
|
|
|
|
|
|
|
your bug as I make changes. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 SUPPORT |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
perldoc Git::Repository::Plugin::Blame::Line |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
You can also look for information at: |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=over 4 |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * GitHub (report bugs there) |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * CPAN Ratings |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * MetaCPAN |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
L |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=back |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 AUTHOR |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
L, |
232
|
|
|
|
|
|
|
C<< >>. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Copyright 2012-2014 Guillaume Aubert. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
240
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
241
|
|
|
|
|
|
|
Software Foundation. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
244
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
245
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
248
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=cut |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
1; |