1 package Gitalist::Git::Head;
4 use namespace::autoclean;
6 with 'Gitalist::Git::Serializable';
8 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
9 use MooseX::Types::Moose qw/Maybe/;
10 use Gitalist::Git::Types qw/SHA1 DateTime/;
12 use aliased 'DateTime' => 'DT';
14 has sha1 => ( isa => SHA1,
18 has name => ( isa => NonEmptySimpleStr,
22 has committer => ( isa => NonEmptySimpleStr,
26 has last_change => ( isa => Maybe[DateTime],
31 around BUILDARGS => sub {
35 if ( @_ == 1 && ! ref $_[0] ) {
37 # expects $line to match the output from
38 # for-each-ref --format=%(objectname)%00%(refname)%00%(committer)
39 my ($sha1, $name, $commitinfo) = split /\0/, $line, 3;
40 $name =~ s!^refs/heads/!!;
42 my ($committer, $epoch, $tz) =
43 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
44 my $dt = DT->from_epoch(
52 committer => $committer,
56 return $class->$orig(@_);