1 package Git::PurePerl::NewObject::Commit;
3 use MooseX::StrictConstructor;
4 use Moose::Util::TypeConstraints;
6 use namespace::autoclean;
8 extends 'Git::PurePerl::NewObject';
11 ( is => 'ro', isa => 'ObjectKind', required => 1, default => 'commit' );
12 has 'tree' => ( is => 'rw', isa => 'Str', required => 1 );
13 has 'parent' => ( is => 'rw', isa => 'Str', required => 0 );
14 has 'author' => ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 );
15 has 'authored_time' => ( is => 'rw', isa => 'DateTime', required => 1 );
17 ( is => 'rw', isa => 'Git::PurePerl::Actor', required => 1 );
18 has 'committed_time' => ( is => 'rw', isa => 'DateTime', required => 1 );
19 has 'comment' => ( is => 'rw', isa => 'Str', required => 1 );
25 $content .= 'tree ' . $self->tree . "\n";
26 $content .= 'parent ' . $self->parent . "\n" if $self->parent;
29 . $self->author->name . ' <'
30 . $self->author->email . "> "
31 . $self->authored_time->epoch . " "
32 . DateTime::TimeZone->offset_as_string( $self->authored_time->offset )
36 . $self->committer->name . ' <'
37 . $self->author->email . "> "
38 . $self->committed_time->epoch . " "
39 . DateTime::TimeZone->offset_as_string(
40 $self->committed_time->offset )
43 my $comment = $self->comment;
45 $content .= "$comment\n";
47 $self->content($content);
50 __PACKAGE__->meta->make_immutable;