1 package Gitalist::Git::Head;
3 use namespace::autoclean;
5 use Gitalist::Git::Types qw/SHA1/;
6 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
7 use MooseX::Types::DateTime;
10 has sha1 => ( isa => SHA1,
14 has name => ( isa => NonEmptySimpleStr,
18 has committer => ( isa => NonEmptySimpleStr,
22 has last_change => ( isa => 'DateTime',
28 around BUILDARGS => sub {
32 if ( @_ == 1 && ! ref $_[0] ) {
34 # expects $line to match the output from
35 # for-each-ref --format=%(objectname)%00%(refname)%00%(committer)
36 my ($sha1, $name, $commitinfo) = split /\0/, $line, 3;
37 $name =~ s!^refs/heads/!!;
39 my ($committer, $epoch, $tz) =
40 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
41 my $dt = DateTime->from_epoch(
49 committer => $committer,
53 return $class->$orig(@_);