line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::Object::Commit; |
2
|
4
|
|
|
4
|
|
18
|
use Moose; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
25
|
|
3
|
4
|
|
|
4
|
|
20324
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
43
|
|
4
|
4
|
|
|
4
|
|
9149
|
use Moose::Util::TypeConstraints; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
33
|
|
5
|
4
|
|
|
4
|
|
8495
|
use Encode qw/decode/; |
|
4
|
|
|
|
|
30307
|
|
|
4
|
|
|
|
|
313
|
|
6
|
4
|
|
|
4
|
|
35
|
use namespace::autoclean; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
47
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Git::PurePerl::Object'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'kind' => |
11
|
|
|
|
|
|
|
( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' ); |
12
|
|
|
|
|
|
|
has 'tree_sha1' => ( is => 'rw', isa => 'Str', required => 0 ); |
13
|
|
|
|
|
|
|
has 'parent_sha1s' => ( is => 'rw', isa => 'ArrayRef[Str]', required => 0, default => sub { [] }); |
14
|
|
|
|
|
|
|
has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); |
15
|
|
|
|
|
|
|
has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); |
16
|
|
|
|
|
|
|
has 'committer' => |
17
|
|
|
|
|
|
|
( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); |
18
|
|
|
|
|
|
|
has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); |
19
|
|
|
|
|
|
|
has 'comment' => ( is => 'rw', isa => 'Str', required => 0 ); |
20
|
|
|
|
|
|
|
has 'encoding' => ( is => 'rw', isa => 'Str', required => 0 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %method_map = ( |
23
|
|
|
|
|
|
|
'tree' => 'tree_sha1', |
24
|
|
|
|
|
|
|
'parent' => '_push_parent_sha1', |
25
|
|
|
|
|
|
|
'author' => 'authored_time', |
26
|
|
|
|
|
|
|
'committer' => 'committed_time' |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub BUILD { |
30
|
155
|
|
|
155
|
0
|
223
|
my $self = shift; |
31
|
155
|
50
|
|
|
|
4515
|
return unless $self->content; |
32
|
155
|
|
|
|
|
3859
|
my @lines = split "\n", $self->content; |
33
|
155
|
|
|
|
|
280
|
my %header; |
34
|
155
|
|
|
|
|
457
|
while ( my $line = shift @lines ) { |
35
|
604
|
50
|
|
|
|
888
|
last unless $line; |
36
|
604
|
|
|
|
|
941
|
my ( $key, $value ) = split ' ', $line, 2; |
37
|
604
|
|
|
|
|
503
|
push @{$header{$key}}, $value; |
|
604
|
|
|
|
|
1819
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
$header{encoding} |
40
|
155
|
|
50
|
|
|
4434
|
||= [ $self->git->config->get(key => "i18n.commitEncoding") || "utf-8" ]; |
|
|
|
100
|
|
|
|
|
41
|
155
|
|
|
|
|
88847
|
my $encoding = $header{encoding}->[-1]; |
42
|
155
|
|
|
|
|
601
|
for my $key (keys %header) { |
43
|
756
|
|
|
|
|
873
|
for my $value (@{$header{$key}}) { |
|
756
|
|
|
|
|
1379
|
|
44
|
758
|
|
|
|
|
1943
|
$value = decode($encoding, $value); |
45
|
758
|
100
|
100
|
|
|
26750
|
if ( $key eq 'committer' or $key eq 'author' ) { |
46
|
310
|
|
|
|
|
1372
|
my @data = split ' ', $value; |
47
|
310
|
|
|
|
|
841
|
my ( $email, $epoch, $tz ) = splice( @data, -3 ); |
48
|
310
|
|
|
|
|
911
|
$email = substr( $email, 1, -1 ); |
49
|
310
|
|
|
|
|
655
|
my $name = join ' ', @data; |
50
|
310
|
|
|
|
|
9360
|
my $actor |
51
|
|
|
|
|
|
|
= Git::PurePerl::Actor->new( name => $name, email => $email ); |
52
|
310
|
|
|
|
|
9774
|
$self->$key($actor); |
53
|
310
|
|
|
|
|
518
|
$key = $method_map{$key}; |
54
|
310
|
|
|
|
|
1711
|
my $dt |
55
|
|
|
|
|
|
|
= DateTime->from_epoch( epoch => $epoch, time_zone => $tz ); |
56
|
310
|
|
|
|
|
147995
|
$self->$key($dt); |
57
|
|
|
|
|
|
|
} else { |
58
|
448
|
|
66
|
|
|
1426
|
$key = $method_map{$key} || $key; |
59
|
448
|
|
|
|
|
10644
|
$self->$key($value); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
155
|
|
|
|
|
636
|
$self->comment( decode($encoding, join "\n", @lines) ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub tree { |
68
|
13
|
|
|
13
|
0
|
28
|
my $self = shift; |
69
|
13
|
|
|
|
|
539
|
return $self->git->get_object( $self->tree_sha1 ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _push_parent_sha1 { |
74
|
138
|
|
|
138
|
|
228
|
my ($self, $sha1) = @_; |
75
|
|
|
|
|
|
|
|
76
|
138
|
|
|
|
|
235
|
push(@{$self->parent_sha1s}, $sha1); |
|
138
|
|
|
|
|
4600
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub parent_sha1 { |
80
|
19
|
|
|
19
|
0
|
751
|
return shift->parent_sha1s->[0]; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub parent { |
84
|
10
|
|
|
10
|
0
|
21
|
my $self = shift; |
85
|
10
|
|
|
|
|
394
|
return $self->git->get_object( $self->parent_sha1 ); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub parents { |
89
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return map { $self->git->get_object( $_ ) } @{$self->parent_sha1s}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
95
|
|
|
|
|
|
|
|