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/;
11 use MooseX::Types::DateTime qw/ DateTime /;
13 use aliased 'DateTime' => 'DT';
15 has sha1 => ( isa => SHA1,
19 has name => ( isa => NonEmptySimpleStr,
24 has type => ( isa => NonEmptySimpleStr,
29 has ref_sha1 => ( isa => Maybe[SHA1],
33 has ref_type => ( isa => Maybe[NonEmptySimpleStr],
37 has committer => ( isa => NonEmptySimpleStr,
41 has last_change => ( isa => Maybe[DateTime],
46 around BUILDARGS => sub {
50 if ( @_ == 1 && ! ref $_[0] ) {
52 # expects $line to match the output from
53 # --format=%(objectname) %(objecttype) %(refname) %(*objectname) %(*objecttype) %(subject)%00%(creator)
54 my ($sha1, $type, $name, $ref_sha1, $ref_type, $rest) = split / /, $line, 6;
55 $name =~ s!^refs/tags/!!;
58 ($ref_sha1, $ref_type) = (undef, undef);
60 my ($subject, $commitinfo) = split /\0/, $rest, 2;
61 my ($committer, $epoch, $tz) =
62 $commitinfo =~ /(.*)\s(\d+)\s+([+-]\d+)$/;
63 my $dt = DT->from_epoch(
72 committer => $committer,
74 ref_sha1 => $ref_sha1,
75 ref_type => $ref_type,
78 return $class->$orig(@_);
84 # Ignore tags like - http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec
85 return /^\S+ \S+ \S+ (?:\S+)? (?:\S+)?[^\0]+\0.*\s\d+\s+[+-]\d+$/;