1 package Gitalist::Git::Tag;
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,
23 has type => ( isa => NonEmptySimpleStr,
28 has ref_sha1 => ( isa => Maybe[SHA1],
32 has ref_type => ( isa => Maybe[NonEmptySimpleStr],
36 has committer => ( isa => NonEmptySimpleStr,
40 has last_change => ( isa => Maybe[DateTime],
45 around BUILDARGS => sub {
49 if ( @_ == 1 && ! ref $_[0] ) {
51 # expects $line to match the output from
52 # --format=%(objectname) %(objecttype) %(refname) %(*objectname) %(*objecttype) %(subject)%00%(creator)
53 my ($sha1, $type, $name, $ref_sha1, $ref_type, $rest) = split / /, $line, 6;
54 $name =~ s!^refs/tags/!!;
57 ($ref_sha1, $ref_type) = (undef, undef);
59 my ($subject, $commitinfo) = split /\0/, $rest, 2;
60 my ($committer, $epoch, $tz) =
61 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
62 my $dt = DT->from_epoch(
71 committer => $committer,
73 ref_sha1 => $ref_sha1,
74 ref_type => $ref_type,
77 return $class->$orig(@_);
83 # Ignore tags like - http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec
84 return /^\S+ \S+ \S+ (?:\S+)? (?:\S+)?[^\0]+\0.*\s\d+\s+[+-]\d+$/;