| 1 | package Git::PurePerl::Object::Commit; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Encode qw/decode/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | extends 'Git::PurePerl::Object'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | has 'kind' => | |||||||||||||||||||||||||||
| 11 | ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' ); | ||||||||||||||||||||||||||||
| 12 | 4 | has 'tree_sha1' => ( is => 'rw', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||
| 13 | 47 | ▶ | has 'parent_sha1s' => ( is => 'rw', isa => 'ArrayRef[Str]', required => 0, default => sub { [] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); | |||||||||||||||||||||||||||
| 15 | 4 | has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); | |||||||||||||||||||||||||||
| 16 | 4 | has 'committer' => | |||||||||||||||||||||||||||
| 17 | ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 0 ); | ||||||||||||||||||||||||||||
| 18 | 4 | has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 0 ); | |||||||||||||||||||||||||||
| 19 | 4 | has 'comment' => ( is => 'rw', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||
| 20 | 4 | has 'encoding' => ( is => 'rw', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 4 | my %method_map = ( | |||||||||||||||||||||||||||
| 23 | 'tree' => 'tree_sha1', | ||||||||||||||||||||||||||||
| 24 | 'parent' => '_push_parent_sha1', | ||||||||||||||||||||||||||||
| 25 | 'author' => 'authored_time', | ||||||||||||||||||||||||||||
| 26 | 'committer' => 'committed_time' | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 47 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=11 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 47 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | 47 | ▶ | return unless $self->content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 47 | my @lines = split "\n", $self->content; | |||||||||||||||||||||||||||
| 33 | 47 | my %header; | |||||||||||||||||||||||||||
| 34 | 47 | ▶ | while ( my $line = shift @lines ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 171 | ▶ | last unless $line; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 171 | my ( $key, $value ) = split ' ', $line, 2; | |||||||||||||||||||||||||||
| 37 | 171 | push @{$header{$key}}, $value; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | $header{encoding} | ||||||||||||||||||||||||||||
| 40 | 47 | ▶ | ||= [ $self->git->config->get(key => "i18n.commitEncoding") || "utf-8" ]; | ||||||||||||||||||||||||||
|
Condition75%3/4
$header{"encoding"} ||= [$self->git->config->get("key", "i18n.commitEncoding") || "utf-8"]
$self->git->config->get('key', 'i18n.commitEncoding') || 'utf-8'
MC/DC100%1/1
$header{"encoding"} ||= [$self->git->config->get("key", "i18n.commitEncoding") || "utf-8"]
$header{"encoding"}
MC/DC0%0/1
$self->git->config->get('key', 'i18n.commitEncoding') || 'utf-8'
$self->git->config->get('key', 'i18n.commitEncoding')
Truth table100%2/2
A
A= $header{"encoding"}
Truth table50%1/2
A
A= $self->git->config->get('key', 'i18n.commitEncoding')
| |||||||||||||||||||||||||||||
| 41 | 47 | my $encoding = $header{encoding}->[-1]; | |||||||||||||||||||||||||||
| 42 | 47 | for my $key (keys %header) { | |||||||||||||||||||||||||||
| 43 | 217 | for my $value (@{$header{$key}}) { | |||||||||||||||||||||||||||
| 44 | 217 | $value = decode($encoding, $value); | |||||||||||||||||||||||||||
| 45 | 217 | ▶ | if ( $key eq 'committer' or $key eq 'author' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "committer" or $key eq "author"
MC/DC100%2/2
$key eq "committer" or $key eq "author"
$key eq "committer"
$key eq "author"
Truth table100%3/3
A or B
A= $key eq "committer"B= $key eq "author"
| |||||||||||||||||||||||||||||
| 46 | 94 | my @data = split ' ', $value; | |||||||||||||||||||||||||||
| 47 | 94 | my ( $email, $epoch, $tz ) = splice( @data, -3 ); | |||||||||||||||||||||||||||
| 48 | 94 | $email = substr( $email, 1, -1 ); | |||||||||||||||||||||||||||
| 49 | 94 | my $name = join ' ', @data; | |||||||||||||||||||||||||||
| 50 | 94 | my $actor | |||||||||||||||||||||||||||
| 51 | = Git::PurePerl::Actor->new( name => $name, email => $email ); | ||||||||||||||||||||||||||||
| 52 | 94 | $self->$key($actor); | |||||||||||||||||||||||||||
| 53 | 94 | $key = $method_map{$key}; | |||||||||||||||||||||||||||
| 54 | 94 | my $dt | |||||||||||||||||||||||||||
| 55 | = DateTime->from_epoch( epoch => $epoch, time_zone => $tz ); | ||||||||||||||||||||||||||||
| 56 | 94 | $self->$key($dt); | |||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||
| 58 | 123 | ▶ | $key = $method_map{$key} || $key; | ||||||||||||||||||||||||||
|
Condition66%2/3
$method_map{$key} || $key
MC/DC0%0/2
$method_map{$key} || $key
$method_map{$key}
$key
Truth table66%2/3
A || B
A= $method_map{$key}B= $key
| |||||||||||||||||||||||||||||
| 59 | 123 | $self->$key($value); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 47 | $self->comment( decode($encoding, join "\n", @lines) ); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 13 | ▶ | sub tree { | ||||||||||||||||||||||||||
|
Subroutine
tree: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 69 | 13 | return $self->git->get_object( $self->tree_sha1 ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 29 | ▶ | sub _push_parent_sha1 { | ||||||||||||||||||||||||||
|
Subroutine
_push_parent_sha1: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 74 | 29 | my ($self, $sha1) = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 29 | push(@{$self->parent_sha1s}, $sha1); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 19 | ▶ | sub parent_sha1 { | ||||||||||||||||||||||||||
|
Subroutine
parent_sha1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 19 | return shift->parent_sha1s->[0]; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 10 | ▶ | sub parent { | ||||||||||||||||||||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | 10 | return $self->git->get_object( $self->parent_sha1 ); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub parents { | ||||||||||||||||||||||||||
|
Subroutine
parents: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | return map { $self->git->get_object( $_ ) } @{$self->parent_sha1s}; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||