| 1 | use 5.008; # utf8 | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use utf8; | ||
| 5 | |||
| 6 | package Git::Wrapper::Plus::Ref::Tag; | ||
| 7 | $Git::Wrapper::Plus::Ref::Tag::VERSION = '0.004010'; | ||
| 8 | # ABSTRACT: A single tag object | ||
| 9 | |||
| 10 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | use Moo qw( extends ); | ||
| 25 | extends 'Git::Wrapper::Plus::Ref'; | ||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | ## no critic(NamingConventions::ProhibitMixedCaseSubs) | ||
| 52 | sub new_from_Ref { | ||
| 53 | my ( $class, $source_object ) = @_; | ||
| 54 | if ( not $source_object->can('name') ) { | ||
| 55 | require Carp; | ||
| 56 | return Carp::croak("Object $source_object does not respond to ->name, cannot Ref -> Tag"); | ||
| 57 | } | ||
| 58 | my $name = $source_object->name; | ||
| 59 | ## no critic ( Compatibility::PerlMinimumVersionAndWhy ) | ||
| 60 | if ( $name =~ qr{\Arefs/tags/(.+\z)}msx ) { | ||
| 61 | return $class->new( | ||
| 62 | git => $source_object->git, | ||
| 63 | name => $1, | ||
| 64 | ); | ||
| 65 | } | ||
| 66 | require Carp; | ||
| 67 | Carp::croak("Path $name is not in refs/tags/*, cannot convert to Tag object"); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | sub refname { | ||
| 81 | my ($self) = @_; | ||
| 82 | return 'refs/tags/' . $self->name; | ||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | sub verify { | ||
| 90 | my ( $self, ) = @_; | ||
| 91 | return $self->git->tag( '-v', $self->name ); | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | ## no critic (ProhibitBuiltinHomonyms) | ||
| 99 | |||
| 100 | sub delete { | ||
| 101 | my ( $self, ) = @_; | ||
| 102 | return $self->git->tag( '-d', $self->name ); | ||
| 103 | } | ||
| 104 | |||
| 105 | no Moo; | ||
| 106 | 1; | ||
| 107 | |||
| 108 | __END__ |