blib/lib/Dist/Zilla/Plugin/BumpVersionFromGit.pm

filter: Statementstmt 65.2% 30 / 46 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 59.3% 38 / 64 CC 5 SCAR 25.0
CC
5
Cov
56%
provide_version
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 12.2
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Dist::Zilla::Plugin::BumpVersionFromGit;
4 # ABSTRACT: DEPRECATED -- use Dist::Zilla::Plugin::Git::NextVersion instead
5  
6 2 our $VERSION = '0.010';
7  
8 2 ▶use Dist::Zilla 4 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Git::Wrapper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use version 0.80 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use namespace::autoclean 0.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 with 'Dist::Zilla::Role::VersionProvider';
16  
17 # -- attributes
18  
19 2 has version_regexp => ( is => 'ro', isa=>'Str', default => '^v(.+)$' );
20  
21 2 has first_version => ( is => 'ro', isa=>'Str', default => '0.001' );
22  
23 # -- role implementation
24  
25 0 ▶sub provide_version {
Subroutine provide_version: not called CC=5 SCAR=34.0
Pod undocumented
26 0 my ($self) = @_;
27  
28 0 require Version::Next;
29  
30 # override (or maybe needed to initialize)
31 0 ▶ return $ENV{V} if exists $ENV{V};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"V"} 0 0 0
32  
33 0 my $git = Git::Wrapper->new('.');
34 0 my $regexp = $self->version_regexp;
35  
36 0 my @tags = $git->tag;
37 0 ▶ return $self->first_version unless @tags;
Branch: 1 branch
BranchTrueFalseTotal
unless @tags 0 0 0
38  
39 # find highest version from tags
40 0 my ($last_ver) = sort { version->parse($b) <=> version->parse($a) }
41 0 grep { eval { version->parse($_) } }
42 0 ▶ map { /$regexp/ ? $1 : () } @tags;
Branch: 1 branch
BranchTrueFalseTotal
/$regexp/ ? : 0 0 0
43  
44 0 ▶ $self->log_fatal("Could not determine last version from tags")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $last_ver 0 0 0
45 unless defined $last_ver;
46  
47 0 my $new_ver = Version::Next::next_version($last_ver);
48 0 $self->log("Bumping version from $last_ver to $new_ver");
49  
50 0 $self->zilla->version("$new_ver");
51 }
52  
53 2 __PACKAGE__->meta->make_immutable;
54 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 2 1;
56  
57 __END__
↑ Summary