Changelord/Role/GitRepo.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 88.3% 38 / 43 CC 4 SCAR 6.2
CC
4
Cov
89%
_get_comparison_data
3.1
_build_stats
2.0
__ANON__
2.0
CRAP 1.9
« Changelord/Command/Validate.pm ↑ Summary Changelord/Role/ChangeTypes.pm »
1 package App::Changelord::Role::GitRepo;
2 5 our $AUTHORITY = 'cpan:YANICK';
3 5 $App::Changelord::Role::GitRepo::VERSION = '0.0.2';
4 5 ▶use v5.36.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Git::Repository;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use feature 'try'; no warnings qw/ experimental /;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 requires 'changelog';
13  
14 # stolen from Dist::Zilla::Plugin::ChangeStats::Git
15  
16 has repo => (
17 is => 'lazy',
18 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 0 Git::Repository->new( work_tree => '.' )
20 },
21 5 );
22  
23 5 has stats => ( is => 'lazy' );
24  
25 1 ▶sub _build_stats ($self) {
Subroutine _build_stats: called CC=2 SCAR=7.1
26 1 ▶ my $comparison_data = $self->_get_comparison_data or return;
Branch: 1 branch
BranchTrueFalseTotal
my $comparison_data = $self->_get_comparison_data or return 1 0 1
27  
28 1 my $stats = 'code churn: ' . $comparison_data;
29 1 return $stats =~ s/\s+/ /gr;
30 }
31  
32 1 ▶sub _get_comparison_data($self) {
Subroutine _get_comparison_data: called CC=3 SCAR=11.3
33  
34 # HEAD versus previous release
35 # What are we diffing against? :)
36 my $previous = $self->changelog->{releases}->@* > 1
37 ? $self->changelog->{releases}[1]{version}
38 1 ▶ : '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; # empty tree
Branch: 1 branch
BranchTrueFalseTotal
@{$self->changelog->{'releases'}} > 1 ? : 0 1 1
39  
40 1 my $output = eval {
41 1 $self->repo->run( 'diff', '--shortstat', $previous, 'HEAD')
42 };
43  
44  
45 1 ▶ warn "could not gather stats: $@\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
46  
47 1 return $output;
48 }
49  
50 5 1;
51  
52 __END__
« Changelord/Command/Validate.pm ↑ Summary Changelord/Role/ChangeTypes.pm »