line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Repository::Plugin::Blame::Line; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
20907
|
use warnings; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
290
|
|
4
|
9
|
|
|
9
|
|
40
|
use strict; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
190
|
|
5
|
9
|
|
|
9
|
|
168
|
use 5.006; |
|
9
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
44
|
use Carp; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
4774
|
|
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.4.0 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '1.4.0'; |
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
|
32
|
|
|
32
|
1
|
4477
|
my ( $class, %args ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Verify parameters. |
91
|
32
|
|
|
|
|
69
|
foreach my $arg ( qw( line_number commit_id ) ) |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
croak "The argument '$arg' must be defined to create a Git::Repository::Plugin::Blame::Line object" |
94
|
63
|
100
|
66
|
|
|
373
|
if !defined( $args{$arg} ) || ( $args{$arg} eq '' ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
croak "The argument 'line' must be defined to create a Git::Repository::Plugin::Blame::Line object" |
97
|
30
|
100
|
|
|
|
84
|
if !defined( $args{'line'} ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
croak "The argument 'line_number' must be a strictly positive integer" |
100
|
29
|
100
|
|
|
|
174
|
if $args{'line_number'} !~ /^\d+$/; |
101
|
|
|
|
|
|
|
|
102
|
28
|
|
|
|
|
36
|
my $commit_attributes = $args{'commit_attributes'}; |
103
|
28
|
100
|
66
|
|
|
147
|
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
|
27
|
|
|
|
|
99
|
foreach my $name ( keys %$commit_attributes ) |
108
|
|
|
|
|
|
|
{ |
109
|
232
|
100
|
|
|
|
418
|
next unless $name =~ /^(?:author|committer)-mail$/x; |
110
|
43
|
|
|
|
|
98
|
$commit_attributes->{ $name } =~ s/^/; |
111
|
43
|
|
|
|
|
95
|
$commit_attributes->{ $name } =~ s/>$//; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Create and return the object. |
115
|
|
|
|
|
|
|
return bless( |
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
line_number => $args{'line_number'}, |
118
|
|
|
|
|
|
|
line => $args{'line'}, |
119
|
|
|
|
|
|
|
commit_attributes => $args{'commit_attributes'}, |
120
|
27
|
|
|
|
|
221
|
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
|
7148
|
my ( $self ) = @_; |
138
|
|
|
|
|
|
|
|
139
|
5
|
|
|
|
|
26
|
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
|
1345
|
my ( $self ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
|
|
9
|
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
|
2354
|
my ( $self ) = @_; |
170
|
|
|
|
|
|
|
|
171
|
5
|
|
|
|
|
27
|
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
|
14
|
|
|
14
|
1
|
5048
|
my ( $self ) = @_; |
186
|
|
|
|
|
|
|
|
187
|
14
|
|
|
|
|
73
|
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-2017 Guillaume Aubert. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This code is free software; you can redistribute it and/or modify it under the |
240
|
|
|
|
|
|
|
same terms as Perl 5 itself. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
243
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
244
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the LICENSE file for more details. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
1; |