| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Cogit::Object::Commit; |
|
2
|
|
|
|
|
|
|
$Cogit::Object::Commit::VERSION = '0.001001'; |
|
3
|
4
|
|
|
4
|
|
12
|
use Moo; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
19
|
|
|
4
|
4
|
|
|
4
|
|
7418
|
use MooX::Types::MooseLike::Base qw( ArrayRef Str InstanceOf ); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
212
|
|
|
5
|
4
|
|
|
4
|
|
1879
|
use Encode qw/decode/; |
|
|
4
|
|
|
|
|
28565
|
|
|
|
4
|
|
|
|
|
249
|
|
|
6
|
4
|
|
|
4
|
|
1283
|
use Cogit::Actor; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
114
|
|
|
7
|
4
|
|
|
4
|
|
2819
|
use DateTime; |
|
|
4
|
|
|
|
|
1315646
|
|
|
|
4
|
|
|
|
|
188
|
|
|
8
|
4
|
|
|
4
|
|
31
|
use namespace::clean; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Cogit::Object'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has '+git' => ( required => 1 ); |
|
13
|
|
|
|
|
|
|
has '+kind' => ( default => sub { 'commit' } ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has tree_sha1 => ( |
|
16
|
|
|
|
|
|
|
is => 'rw', |
|
17
|
|
|
|
|
|
|
isa => Str, |
|
18
|
|
|
|
|
|
|
init_arg => 'tree', |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has _parent => ( |
|
22
|
|
|
|
|
|
|
init_arg => 'parent', |
|
23
|
|
|
|
|
|
|
is => 'rw', |
|
24
|
|
|
|
|
|
|
isa => Str, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has parent_sha1s => ( |
|
28
|
|
|
|
|
|
|
is => 'rw', |
|
29
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
|
30
|
|
|
|
|
|
|
default => sub { [] }, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has author => ( |
|
34
|
|
|
|
|
|
|
is => 'rw', |
|
35
|
|
|
|
|
|
|
isa => InstanceOf['Cogit::Actor'], |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has authored_time => ( |
|
39
|
|
|
|
|
|
|
is => 'rw', |
|
40
|
|
|
|
|
|
|
isa => InstanceOf['DateTime'], |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has committer => ( |
|
44
|
|
|
|
|
|
|
is => 'rw', |
|
45
|
|
|
|
|
|
|
isa => InstanceOf['Cogit::Actor'], |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has committed_time => ( |
|
49
|
|
|
|
|
|
|
is => 'rw', |
|
50
|
|
|
|
|
|
|
isa => InstanceOf['DateTime'], |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has comment => ( |
|
54
|
|
|
|
|
|
|
is => 'rw', |
|
55
|
|
|
|
|
|
|
isa => Str, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has encoding => ( |
|
59
|
|
|
|
|
|
|
is => 'rw', |
|
60
|
|
|
|
|
|
|
isa => Str, |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my %method_map = ( |
|
64
|
|
|
|
|
|
|
tree => 'tree_sha1', |
|
65
|
|
|
|
|
|
|
parent => '_push_parent_sha1', |
|
66
|
|
|
|
|
|
|
author => 'authored_time', |
|
67
|
|
|
|
|
|
|
committer => 'committed_time' |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub BUILD { |
|
71
|
52
|
|
|
52
|
0
|
5713
|
my $self = shift; |
|
72
|
52
|
100
|
|
|
|
256
|
return unless $self->has_content; |
|
73
|
48
|
|
|
|
|
821
|
my @lines = split "\n", $self->content; |
|
74
|
48
|
|
|
|
|
429
|
my %header; |
|
75
|
48
|
|
|
|
|
164
|
while ( my $line = shift @lines ) { |
|
76
|
168
|
50
|
|
|
|
256
|
last unless $line; |
|
77
|
168
|
|
|
|
|
302
|
my ( $key, $value ) = split ' ', $line, 2; |
|
78
|
168
|
|
|
|
|
161
|
push @{$header{$key}}, $value; |
|
|
168
|
|
|
|
|
567
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
$header{encoding} |
|
81
|
48
|
|
50
|
|
|
1066
|
||= [ $self->git->config->get(key => "i18n.commitEncoding") || "utf-8" ]; |
|
|
|
|
100
|
|
|
|
|
|
82
|
48
|
|
|
|
|
63650
|
my $encoding = $header{encoding}->[-1]; |
|
83
|
48
|
|
|
|
|
197
|
for my $key (keys %header) { |
|
84
|
215
|
|
|
|
|
6754
|
for my $value (@{$header{$key}}) { |
|
|
215
|
|
|
|
|
402
|
|
|
85
|
215
|
|
|
|
|
580
|
$value = decode($encoding, $value); |
|
86
|
215
|
100
|
100
|
|
|
8503
|
if ( $key eq 'committer' or $key eq 'author' ) { |
|
87
|
96
|
|
|
|
|
420
|
my @data = split ' ', $value; |
|
88
|
96
|
|
|
|
|
212
|
my ( $email, $epoch, $tz ) = splice( @data, -3 ); |
|
89
|
96
|
|
|
|
|
308
|
$email = substr( $email, 1, -1 ); |
|
90
|
96
|
|
|
|
|
254
|
my $name = join ' ', @data; |
|
91
|
96
|
|
|
|
|
1996
|
my $actor |
|
92
|
|
|
|
|
|
|
= Cogit::Actor->new( name => $name, email => $email ); |
|
93
|
96
|
|
|
|
|
11508
|
$self->$key($actor); |
|
94
|
96
|
|
|
|
|
4558
|
$key = $method_map{$key}; |
|
95
|
96
|
|
|
|
|
466
|
my $dt |
|
96
|
|
|
|
|
|
|
= DateTime->from_epoch( epoch => $epoch, time_zone => $tz ); |
|
97
|
96
|
|
|
|
|
53666
|
$self->$key($dt); |
|
98
|
|
|
|
|
|
|
} else { |
|
99
|
119
|
|
66
|
|
|
402
|
$key = $method_map{$key} || $key; |
|
100
|
119
|
|
|
|
|
2156
|
$self->$key($value); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
48
|
|
|
|
|
2333
|
$self->comment( decode($encoding, join "\n", @lines) ); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _build_content { |
|
108
|
4
|
|
|
4
|
|
58
|
my $self = shift; |
|
109
|
|
|
|
|
|
|
|
|
110
|
4
|
|
|
|
|
9
|
my $content; |
|
111
|
|
|
|
|
|
|
|
|
112
|
4
|
|
|
|
|
85
|
$content .= 'tree ' . $self->tree_sha1 . "\n"; |
|
113
|
4
|
50
|
|
|
|
43
|
$content .= 'parent ' . $self->parent . "\n" if $self->parent; |
|
114
|
4
|
|
|
|
|
88
|
$content |
|
115
|
|
|
|
|
|
|
.= "author " |
|
116
|
|
|
|
|
|
|
. $self->author->name . ' <' |
|
117
|
|
|
|
|
|
|
. $self->author->email . "> " |
|
118
|
|
|
|
|
|
|
. $self->authored_time->epoch . " " |
|
119
|
|
|
|
|
|
|
. DateTime::TimeZone->offset_as_string( $self->authored_time->offset ) |
|
120
|
|
|
|
|
|
|
. "\n"; |
|
121
|
4
|
|
|
|
|
785
|
$content |
|
122
|
|
|
|
|
|
|
.= "committer " |
|
123
|
|
|
|
|
|
|
. $self->committer->name . ' <' |
|
124
|
|
|
|
|
|
|
. $self->author->email . "> " |
|
125
|
|
|
|
|
|
|
. $self->committed_time->epoch . " " |
|
126
|
|
|
|
|
|
|
. DateTime::TimeZone->offset_as_string( |
|
127
|
|
|
|
|
|
|
$self->committed_time->offset ) |
|
128
|
|
|
|
|
|
|
. "\n"; |
|
129
|
4
|
|
|
|
|
504
|
$content .= "\n"; |
|
130
|
4
|
|
|
|
|
85
|
my $comment = $self->comment; |
|
131
|
4
|
|
|
|
|
31
|
chomp $comment; |
|
132
|
4
|
|
|
|
|
12
|
$content .= "$comment\n"; |
|
133
|
|
|
|
|
|
|
|
|
134
|
4
|
|
|
|
|
62
|
return $content; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub tree { |
|
138
|
14
|
|
|
14
|
0
|
21228
|
my $self = shift; |
|
139
|
14
|
|
|
|
|
307
|
return $self->git->get_object( $self->tree_sha1 ); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _push_parent_sha1 { |
|
144
|
23
|
|
|
23
|
|
32
|
my ($self, $sha1) = @_; |
|
145
|
|
|
|
|
|
|
|
|
146
|
23
|
|
|
|
|
24
|
push(@{$self->parent_sha1s}, $sha1); |
|
|
23
|
|
|
|
|
439
|
|
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub parent_sha1 { |
|
150
|
23
|
|
|
23
|
0
|
21183
|
return shift->parent_sha1s->[0]; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub parent { |
|
154
|
14
|
|
|
14
|
0
|
10346
|
my $self = shift; |
|
155
|
14
|
|
|
|
|
301
|
return $self->git->get_object( $self->parent_sha1 ); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub parents { |
|
159
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return map { $self->git->get_object( $_ ) } @{$self->parent_sha1s}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
__END__ |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=pod |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=encoding UTF-8 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 NAME |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Cogit::Object::Commit |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 VERSION |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
version 0.001001 |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <cogit@afoolishmanifesto.com> |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
189
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |