blib/lib/App/Git/Workflow/Command/SinceRelease.pm

filter: Statementstmt 100% 47 / 47 Branchbran 83.3% 10 / 12 Conditioncond 83.3% 5 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 93.7% 75 / 80 CC 11 SCAR 16.3
CC
11
Cov
95%
run
9.0
newest_tag
3.0
BEGIN
1.0
CRAP 5.1
↑ Summary
1 package App::Git::Workflow::Command::SinceRelease;
2  
3 # Created on: 2014-03-11 20:58:59
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Pod::Usage ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use App::Git::Workflow;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use App::Git::Workflow::Command qw/get_options/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 our $VERSION = 0.4;
18 2 our $workflow = App::Git::Workflow->new;
19 2 our ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs;
20 2 our %option;
21  
22 4 ▶sub run {
Subroutine run: called CC=9 SCAR=22.0
Pod documented
23 4 my ($self) = @_;
24  
25 4 get_options(
26 \%option,
27 'quiet|q',
28 );
29  
30 # get newest tag
31 4 my $tag = $self->newest_tag;
32 4 ▶ return if $option{quiet} && !$tag;
Branch: 1 branch
BranchTrueFalseTotal
if $App::Git::Workflow::Command::SinceRelease::option{"quiet"} and not $tag 0 4 4
Condition66%2/3
$App::Git::Workflow::Command::SinceRelease::option{"quiet"} and not $tag
!ll&&!rl&&r
220
MC/DC0%0/2
$App::Git::Workflow::Command::SinceRelease::option{"quiet"} and not $tag
$App::Git::Workflow::Command::SinceRelease::option{"quiet"} not $tag
Truth table66%2/3
A and not(B)
A= $App::Git::Workflow::Command::SinceRelease::option{"quiet"}B= not $tag
ABresult
0X0
100
111
33  
34 # get rev-parse --all -n 100
35 # stop processing when commit is tag
36 4 my $count = 0;
37 4 my %seen;
38 4 for my $id (reverse $workflow->git->rev_parse("--all")) {
39 8 ▶ next if $seen{$id}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$id}++ 3 5 8
40 5 my $details = $workflow->commit_details($id);
41 5 ▶ next if $details->{time} < $tag;
Branch: 1 branch
BranchTrueFalseTotal
if $details->{"time"} < $tag 2 3 5
42 3 $count++;
43 }
44  
45 4 ▶ print "Ahead by $count commit" . ($count != 1 ? 's' : '') . "\n" if !$option{quiet} || $count;
Branch: 2 branches
BranchTrueFalseTotal
if not $App::Git::Workflow::Command::SinceRelease::option{"quiet"} or $count 3 1 4
$count != 1 ? : 2 1 3
Condition100%3/3
not $App::Git::Workflow::Command::SinceRelease::option{"quiet"} or $count
l!l&&r!l&&!r
211
MC/DC100%2/2
not $App::Git::Workflow::Command::SinceRelease::option{"quiet"} or $count
not $App::Git::Workflow::Command::SinceRelease::option{"quiet"} $count
Truth table100%3/3
not(A) or B
A= not $App::Git::Workflow::Command::SinceRelease::option{"quiet"}B= $count
ABresult
1X1
011
000
46  
47 4 return;
48 }
49  
50 4 ▶sub newest_tag {
Subroutine newest_tag: called CC=3 SCAR=11.0
Pod documented
51 4 my ($self) = @_;
52 4 my ($max_tag, $max_time) = ('', 0);
53  
54 4 for my $tag ($workflow->git->tag) {
55 8 my $details = $workflow->commit_details($tag);
56 8 ▶ if ($details->{time} > $max_time) {
Branch: 1 branch
BranchTrueFalseTotal
if ($details->{"time"} > $max_time) 8 0 8
57 8 $max_time = $details->{time};
58 8 $max_tag = $tag;
59 }
60 }
61  
62 4 return $max_time;
63 }
64  
65 2 1;
66  
67 __DATA__
↑ Summary