| 1 | package Git::PurePerl::NewObject::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 DateTime; | ||||||||
|
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::NewObject'; | |||||||||
| 9 | |||||||||||
| 10 | 4 | has 'kind' => | |||||||||
| 11 | ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' ); | ||||||||||
| 12 | 4 | has 'tree' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||
| 13 | 4 | has 'parent' => ( is => 'rw', isa => 'Str|ArrayRef[Str]', required => 0 ); | |||||||||
| 14 | 4 | has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 ); | |||||||||
| 15 | 4 | has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 1 ); | |||||||||
| 16 | 4 | has 'committer' => | |||||||||
| 17 | ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 ); | ||||||||||
| 18 | 4 | has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 1 ); | |||||||||
| 19 | 4 | has 'comment' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||
| 20 | |||||||||||
| 21 | 4 | ▶ | sub _build_content { | ||||||||
|
Subroutine
_build_content: called CC=4 SCAR=13.9
| |||||||||||
| 22 | 4 | my $self = shift; | |||||||||
| 23 | 4 | my $content; | |||||||||
| 24 | |||||||||||
| 25 | 4 | $content .= 'tree ' . $self->tree . "\n"; | |||||||||
| 26 | 4 | ▶ | if ( my $parent = $self->parent ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 2 | ▶ | if ( ref $parent ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | $content .= "parent $_\n" for @$parent; | |||||||||
| 29 | } | ||||||||||
| 30 | else { | ||||||||||
| 31 | 2 | $content .= "parent $parent\n"; | |||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | $content | ||||||||||
| 35 | 4 | .= "author " | |||||||||
| 36 | . $self->author->name . ' <' | ||||||||||
| 37 | . $self->author->email . "> " | ||||||||||
| 38 | . $self->authored_time->epoch . " " | ||||||||||
| 39 | . DateTime::TimeZone->offset_as_string( $self->authored_time->offset ) | ||||||||||
| 40 | . "\n"; | ||||||||||
| 41 | 4 | $content | |||||||||
| 42 | .= "committer " | ||||||||||
| 43 | . $self->committer->name . ' <' | ||||||||||
| 44 | . $self->author->email . "> " | ||||||||||
| 45 | . $self->committed_time->epoch . " " | ||||||||||
| 46 | . DateTime::TimeZone->offset_as_string( | ||||||||||
| 47 | $self->committed_time->offset ) | ||||||||||
| 48 | . "\n"; | ||||||||||
| 49 | 4 | $content .= "\n"; | |||||||||
| 50 | 4 | my $comment = $self->comment; | |||||||||
| 51 | 4 | chomp $comment; | |||||||||
| 52 | 4 | $content .= "$comment\n"; | |||||||||
| 53 | |||||||||||
| 54 | 4 | $self->content($content); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||
| 58 | |||||||||||