line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Repository::Log; |
2
|
|
|
|
|
|
|
$Git::Repository::Log::VERSION = '1.313'; |
3
|
3
|
|
|
3
|
|
12820
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
66
|
|
4
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
64
|
|
5
|
3
|
|
|
3
|
|
42
|
use 5.006; |
|
3
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# a few simple accessors |
8
|
|
|
|
|
|
|
for my $attr ( |
9
|
|
|
|
|
|
|
qw( |
10
|
|
|
|
|
|
|
commit diff_from tree |
11
|
|
|
|
|
|
|
author author_name author_email |
12
|
|
|
|
|
|
|
committer committer_name committer_email |
13
|
|
|
|
|
|
|
author_localtime author_tz author_gmtime |
14
|
|
|
|
|
|
|
committer_localtime committer_tz committer_gmtime |
15
|
|
|
|
|
|
|
raw_message message subject body |
16
|
|
|
|
|
|
|
gpgsig |
17
|
|
|
|
|
|
|
extra |
18
|
|
|
|
|
|
|
) |
19
|
|
|
|
|
|
|
) |
20
|
|
|
|
|
|
|
{ |
21
|
3
|
|
|
3
|
|
9
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
174
|
|
22
|
207
|
|
|
207
|
|
16460
|
*$attr = sub { return $_[0]{$attr} }; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
for my $attr (qw( parent mergetag )) { |
25
|
3
|
|
|
3
|
|
9
|
no strict 'refs'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1153
|
|
26
|
73
|
100
|
|
73
|
|
10701
|
*$attr = sub { return @{ $_[0]{$attr} || [] } }; |
|
73
|
|
|
|
|
531
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
43
|
|
|
43
|
1
|
1441
|
my ( $class, @args ) = @_; |
31
|
43
|
|
|
|
|
142
|
my $self = bless { parent => [] }, $class; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# pick up key/values from the list |
34
|
43
|
|
|
|
|
153
|
while ( my ( $key, $value ) = splice @args, 0, 2 ) { |
35
|
344
|
100
|
|
|
|
633
|
if ( $key =~ /^(?:parent|mergetag)$/ ) { |
36
|
77
|
|
|
|
|
67
|
push @{ $self->{$key} }, $value; |
|
77
|
|
|
|
|
230
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
267
|
|
|
|
|
778
|
$self->{$key} = $value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# special case |
44
|
43
|
|
|
|
|
258
|
($self->{commit}, $self->{diff_from}) = $self->{commit} =~ /^(\S+)(?: \(from (\S+)\))?/; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# compute other keys |
47
|
43
|
|
|
|
|
79
|
$self->{raw_message} = $self->{message}; |
48
|
43
|
|
|
|
|
196
|
$self->{message} =~ s/^ //gm; |
49
|
43
|
|
|
|
|
118
|
@{$self}{qw( subject body )} |
50
|
43
|
|
|
|
|
106
|
= ( split( /\n/m, $self->{message}, 2 ), '', '' ); |
51
|
43
|
|
|
|
|
119
|
$self->{body} =~ s/\A\s//gm; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# author and committer details |
54
|
43
|
|
|
|
|
70
|
for my $who (qw( author committer )) { |
55
|
86
|
|
|
|
|
353
|
$self->{$who} =~ /^(.*) <(.*)> (.*) (([-+])(..)(..))$/; |
56
|
86
|
|
|
|
|
253
|
my @keys = ( "${who}_name", "${who}_email", "${who}_gmtime", |
57
|
|
|
|
|
|
|
"${who}_tz" ); |
58
|
86
|
|
|
|
|
100
|
@{$self}{@keys} = ( $1, $2, $3, $4 ); |
|
86
|
|
|
|
|
473
|
|
59
|
86
|
100
|
|
|
|
586
|
$self->{"${who}_localtime"} = $self->{"${who}_gmtime"} |
60
|
|
|
|
|
|
|
+ ( $5 eq '-' ? -1 : 1 ) * ( $6 * 3600 + $7 * 60 ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
43
|
|
|
|
|
252
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Git::Repository::Log - Class representing git log data |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# load the Log plugin |
79
|
|
|
|
|
|
|
use Git::Repository 'Log'; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# get the log for last commit |
82
|
|
|
|
|
|
|
my ($log) = Git::Repository->log( '-1' ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# get the author's email |
85
|
|
|
|
|
|
|
print my $email = $log->author_email; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 DESCRIPTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
C<Git::Repository::Log> is a class whose instances represent |
90
|
|
|
|
|
|
|
log items from a B<git log> stream. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method shouldn't be used directly. L<Git::Repository::Log::Iterator> |
95
|
|
|
|
|
|
|
should be the preferred way to create C<Git::Repository::Log> objects. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 new |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Create a new C<Git::Repository::Log> instance, using the list of key/values |
100
|
|
|
|
|
|
|
passed as parameters. The supported keys are (from the output of |
101
|
|
|
|
|
|
|
C<git log --pretty=raw>): |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item commit |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The commit id (ignoring the extra information added by I<--decorate>). |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item tree |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The tree id. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item parent |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The parent list, separated by spaces. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item author |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
The author information. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item committer |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The committer information. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item message |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The log message (including the 4-space indent normally output by B<git log>). |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item gpgsig |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The commit signature. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item mergetag |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The mergetag information. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item diff_from |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The commit from which the diff was taken. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This is the extra C<from> information on the commit header that is |
142
|
|
|
|
|
|
|
added by B<git> when the log contains a diff (using the C<-p> or |
143
|
|
|
|
|
|
|
C<--name-status> option). In this case, C<git log> may show the same |
144
|
|
|
|
|
|
|
commit several times. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item extra |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Any extra text that might be added by extra options passed to B<git log> |
149
|
|
|
|
|
|
|
(e.g. C<-p> or C<--name-status>). |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Note that since C<git tag --pretty=raw> does not provide the C<encoding> |
154
|
|
|
|
|
|
|
header (and provides the message properly decoded), this information |
155
|
|
|
|
|
|
|
will not be available via L<Git::Repository::Plugin::Log>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 ACCESSORS |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The following accessors methods are recognized. They all return scalars, |
160
|
|
|
|
|
|
|
except for C<parent()>, which returns a list. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 Commit information |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=over 4 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item commit |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item tree |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item parent |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 Author and committer information |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over 4 |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item author |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item committer |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
The original author/committer line |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item author_name |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item committer_name |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item author_email |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item committer_email |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=back |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 Date information |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=over 4 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item author_gmtime |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item committer_gmtime |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item author_localtime |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item committer_localtime |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item author_tz |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item committer_tz |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 Log information |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over 4 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item raw_message |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The log message with the 4-space indent output by B<git log>. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item message |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
The unindented version of the log message. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item subject |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item body |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=back |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 Signature-related information |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over 4 |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item gpgsig |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item mergetag |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=back |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 Extra information |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=over 4 |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item extra |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 COPYRIGHT |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Copyright 2010-2016 Philippe Bruhat (BooK), all rights reserved. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 LICENSE |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
255
|
|
|
|
|
|
|
under the same terms as Perl itself. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=cut |