Role/Git/Repo/More.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 81.8% 27 / 33 CC 2 SCAR 4.1
CC
2
Cov
79%
_build__previous_versions
2.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Plugin/Git/CheckFor/Fixups.pm ↑ Summary PluginBundle/Git/CheckFor.pm »
1 #
2 # This file is part of Dist-Zilla-PluginBundle-Git-CheckFor
3 #
4 # This software is Copyright (c) 2026 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package Dist::Zilla::Role::Git::Repo::More;
11 7 our $AUTHORITY = 'cpan:RSRCHBOY';
12 7 $Dist::Zilla::Role::Git::Repo::More::VERSION = '0.015';
13 # ABSTRACT: A little more than Dist::Zilla::Role::Git::Repo
14  
15 7 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 7 with
19 'Dist::Zilla::Role::Git::Repo',
20 ;
21  
22 7 has _repo => (is => 'ro', lazy => 1, builder => '_build__repo', isa => 'Git::Wrapper');
23 7 ▶sub _build__repo {
Subroutine _build__repo: called CC=1 SCAR=0.0
24 7 require Git::Wrapper;
25 7 Git::Wrapper->new(shift->repo_root)
26 }
27  
28  
29 # -- attributes
30  
31 #has version_regexp => (is => 'rwp', isa=>'Str', lazy => 1, predicate => 1, builder => sub { '^v(.+)$' });
32 #has first_version => (is => 'rwp', isa=>'Str', lazy => 1, predicate => 1, default => sub { '0.001' });
33  
34 7 has _previous_versions => (
35  
36 traits => ['Array'],
37 is => 'ro',
38 lazy => 1,
39 builder => '_build__previous_versions',
40 isa => 'ArrayRef[Str]',
41 handles => {
42  
43 has_previous_versions => 'count',
44 previous_versions => 'elements',
45 earliest_version => [ get => 0 ],
46 last_version => [ get => -1 ],
47 },
48 );
49  
50 3 ▶sub _build__previous_versions {
Subroutine _build__previous_versions: called CC=2 SCAR=8.1
51 3 my ($self) = @_;
52  
53 3 local $/ = "\n"; # Force record separator to be single newline
54  
55 3 require Git::Wrapper;
56 3 my $git = Git::Wrapper->new( $self->repo_root );
57 3 my $regexp = $self->version_regexp;
58  
59 3 my @tags = $git->tag;
60 0 ▶ @tags = map { /$regexp/ ? $1 : () } @tags;
Branch: 1 branch
BranchTrueFalseTotal
/$regexp/ ? : 0 0 0
61  
62 # find tagged versions; sort least to greatest
63 my @versions =
64 0 sort { version->parse($a) <=> version->parse($b) }
65 0 grep { eval { version->parse($_) } }
66 @tags;
67  
68 3 return [ @versions ];
69 }
70  
71 # -- role implementation
72  
73 #sub provide_version {
74 #my ($self) = @_;
75  
76 ## override (or maybe needed to initialize)
77 #return $ENV{V} if exists $ENV{V};
78  
79 #return $self->first_version
80 #unless $self->has_previous_versions;
81  
82 #my $last_ver = $self->last_version;
83 #my $new_ver = Version::Next::next_version($last_ver);
84 #$self->log("Bumping version from $last_ver to $new_ver");
85  
86 #return "$new_ver";
87 #}
88  
89 7 !!42;
90  
91 __END__
« Plugin/Git/CheckFor/Fixups.pm ↑ Summary PluginBundle/Git/CheckFor.pm »