blib/lib/Dist/Zilla/Plugin/Git/Tag.pm

filter: Statementstmt 97.9% 48 / 49 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 2 totaltotal 87.8% 65 / 74 CC 7 SCAR 8.3
CC
7
Cov
90%
after_release
4.2
__ANON__
3.1
_git_config_mapping
2.0
CRAP 2.3
« blib/lib/Dist/Zilla/Plugin/Git/CommitBuild.pm ↑ Summary blib/lib/Dist/Zilla/Role/Git/DirtyFiles.pm »
1 #
2 # This file is part of Dist-Zilla-Plugin-Git
3 #
4 # This software is copyright (c) 2009 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 4 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Dist::Zilla::Plugin::Git::Tag;
14 # ABSTRACT: Tag the new version
15  
16 4 our $VERSION = '2.052';
17  
18 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Types::Standard qw{ Str Bool};
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 0 ▶sub _git_config_mapping { +{
Subroutine _git_config_mapping: not called CC=1 SCAR=6.9
23 0 changelog => '%{changelog}s',
24 } }
25  
26 # -- attributes
27  
28 4 has tag_format => ( is => 'ro', isa=>Str, default => 'v%V' );
29 4 has tag_message => ( is => 'ro', isa=>Str, default => 'v%V' );
30 4 has changelog => ( is => 'ro', isa=>Str, default => 'Changes' );
31 4 has branch => ( is => 'ro', isa=>Str, predicate=>'has_branch' );
32 4 has signed => ( is => 'ro', isa=>Bool, default=>0 );
33  
34 4 with 'Dist::Zilla::Role::BeforeRelease',
35 'Dist::Zilla::Role::AfterRelease',
36 'Dist::Zilla::Role::Git::Repo';
37 4 with 'Dist::Zilla::Role::Git::StringFormatter';
38 4 with 'Dist::Zilla::Role::GitConfig';
39  
40 #pod =method tag
41 #pod
42 #pod my $tag = $plugin->tag;
43 #pod
44 #pod Return the tag that will be / has been applied by the plugin. That is,
45 #pod returns C<tag_format> as completed with the real values.
46 #pod
47 #pod =cut
48  
49 4 has tag => ( is => 'ro', isa => Str, lazy_build => 1, );
50  
51 sub _build_tag
52 6 ▶{
Subroutine _build_tag: called CC=1 SCAR=0.0
53 6 my $self = shift;
54 6 return $self->_format_string($self->tag_format);
55 }
56  
57  
58 # -- role implementation
59  
60 around dump_config => sub
61 6 ▶{
Subroutine __ANON__: called CC=3 SCAR=11.3
62 6 my $orig = shift;
63 6 my $self = shift;
64  
65 6 my $config = $self->$orig;
66  
67 6 ▶ $config->{+__PACKAGE__} = {
Branch: 2 branches
BranchTrueFalseTotal
$self->signed ? : 0 6 6
builtin::blessed($self) ne __PACKAGE__ ? : 0 6 6
68 (map +($_ => $self->$_), qw(tag_format tag_message changelog branch tag)),
69 signed => $self->signed ? 1 : 0,
70 blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
71 };
72  
73 6 return $config;
74 4 };
75  
76 7 ▶sub before_release {
Subroutine before_release: called CC=2 SCAR=6.9
Pod undocumented
77 7 my $self = shift;
78  
79 # Make sure a tag with the new version doesn't exist yet:
80 7 my $tag = $self->tag;
81 7 ▶ $self->log_fatal("tag $tag already exists")
Branch: 1 branch
BranchTrueFalseTotal
if $self->git->tag("-l", $tag) 1 6 7
82 if $self->git->tag('-l', $tag );
83 }
84  
85 4 ▶sub after_release {
Subroutine after_release: called CC=4 SCAR=14.2
Pod undocumented
86 4 my $self = shift;
87  
88 4 my @opts;
89 4 ▶ push @opts, ( '-m' => $self->_format_string($self->tag_message) )
Branch: 1 branch
BranchTrueFalseTotal
if $self->tag_message 4 0 4
90 if $self->tag_message; # Make an annotated tag if tag_message, lightweight tag otherwise:
91 4 ▶ push @opts, '-s'
Branch: 1 branch
BranchTrueFalseTotal
if $self->signed 0 4 4
92 if $self->signed; # make a GPG-signed tag
93  
94 4 ▶ my @branch = $self->has_branch ? ( $self->branch ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->has_branch ? : 0 4 4
95  
96 # create a tag with the new version
97 4 my $tag = $self->tag;
98 4 $self->git->tag( @opts, $tag, @branch );
99 4 $self->log("Tagged $tag");
100 }
101  
102 4 __PACKAGE__->meta->make_immutable;
103 4 1;
104  
105 __END__
« blib/lib/Dist/Zilla/Plugin/Git/CommitBuild.pm ↑ Summary blib/lib/Dist/Zilla/Role/Git/DirtyFiles.pm »