| 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
Condition66%2/3
$App::Git::Workflow::Command::SinceRelease::option{"quiet"} and not $tag
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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 40 | 5 | my $details = $workflow->commit_details($id); | |||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | next if $details->{time} < $tag; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | 3 | $count++; | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | print "Ahead by $count commit" . ($count != 1 ? 's' : '') . "\n" if !$option{quiet} || $count; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
not $App::Git::Workflow::Command::SinceRelease::option{"quiet"} or $count
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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||