1 package Gitalist::Git::Tag;
3 use namespace::autoclean;
5 use Gitalist::Git::Types qw/SHA1/;
6 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
7 use MooseX::Types::Moose qw/Maybe Str/;
8 use MooseX::Types::DateTime;
11 has sha1 => ( isa => SHA1,
15 has name => ( isa => NonEmptySimpleStr,
20 has type => ( isa => NonEmptySimpleStr,
25 has ref_sha1 => ( isa => Maybe[SHA1],
29 has ref_type => ( isa => Maybe[NonEmptySimpleStr],
33 has committer => ( isa => NonEmptySimpleStr,
37 has last_change => ( isa => 'DateTime',
43 around BUILDARGS => sub {
47 if ( @_ == 1 && ! ref $_[0] ) {
49 # expects $line to match the output from
50 # --format=%(objectname) %(objecttype) %(refname) %(*objectname) %(*objecttype) %(subject)%00%(creator)
51 my ($sha1, $type, $name, $ref_sha1, $ref_type, $rest) = split / /, $line, 6;
52 $name =~ s!^refs/tags/!!;
55 ($ref_sha1, $ref_type) = (undef, undef);
57 my ($subject, $commitinfo) = split /\0/, $rest, 2;
58 my ($committer, $epoch, $tz) =
59 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
60 my $dt = DateTime->from_epoch(
69 committer => $committer,
71 ref_sha1 => $ref_sha1,
72 ref_type => $ref_type,
75 return $class->$orig(@_);