GitGot/Command/tag.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 80.0% 8 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 82.8% 58 / 70 CC 11 SCAR 17.1
CC
11
Cov
86%
_print_tags
9.7
_execute
6.0
BEGIN
1.0
CRAP 5.6
« GitGot/Command/lib.pm ↑ Summary GitGot/Command/remove.pm »
1 package App::GitGot::Command::tag;
2 16 our $AUTHORITY = 'cpan:GENEHACK';
3 16 $App::GitGot::Command::tag::VERSION = '1.339';
4 # ABSTRACT: list/add/remove tags for the current repository
5 16 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 extends 'App::GitGot::Command';
9 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 ▶sub options {
Subroutine options: called CC=1 SCAR=0.0
Pod undocumented
12 7 my( $class , $app ) = @_;
13 return (
14 7 [ 'add|a' => 'assign tags to the current repository' => { default => 0 } ] ,
15 [ 'all|A' => 'print out tags of all repositories' => { default => 0 } ] ,
16 [ 'remove|rm' => 'remove tags from the current repository' => { default => 0 } ] ,
17 );
18 }
19  
20 7 ▶sub _execute {
Subroutine _execute: called CC=6 SCAR=17.9
21 7 my( $self, $opt, $args ) = @_;
22  
23 7 ▶ return say "not in a got-monitored repo" unless $self->local_repo;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->local_repo 0 6 6
24  
25 6 ▶ return say "can't --add and --remove at the same time"
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt->add and $self->opt->remove 1 5 6
Condition100%3/3
$self->opt->add and $self->opt->remove
!ll&&!rl&&r
411
MC/DC100%2/2
$self->opt->add and $self->opt->remove
$self->opt->add $self->opt->remove
Truth table100%3/3
A and B
A= $self->opt->addB= $self->opt->remove
ABresult
0X0
100
111
26 if $self->opt->add and $self->opt->remove;
27  
28 5 ▶ if( $self->opt->add ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt->add) 1 4 5
29 1 return $self->_add_tags( @$args );
30 }
31  
32 4 ▶ if( $self->opt->remove ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt->remove) 1 3 4
33 1 return $self->_remove_tags( @$args );
34 }
35  
36 3 $self->_print_tags;
37 }
38  
39 1 ▶sub _add_tags {
Subroutine _add_tags: called CC=1 SCAR=0.0
40 1 my( $self, @tags ) = @_;
41  
42 1 $self->local_repo->add_tags( @tags );
43  
44 1 $self->write_config;
45  
46 1 say "tags added";
47 }
48  
49 3 ▶sub _print_tags {
Subroutine _print_tags: called CC=6 SCAR=22.7
50 3 my $self = shift;
51  
52 3 my %tags = map { $_ => 1 } split ' ', $self->local_repo->tags;
53  
54 3 ▶ if ( $self->opt->all ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->opt->all) 0 3 3
55 0 ▶ $tags{$_} ||= 0 for map { split ' ', $_->tags } $self->all_repos
Condition0%0/2
$tags{$_} ||= 0
l!l
00
MC/DC0%0/1
$tags{$_} ||= 0
$tags{$_}
Truth table0%0/2
A
A= $tags{$_}
Aresult
11
00
56 }
57  
58 3 for my $t ( sort keys %tags ) {
59 3 ▶ say $t, ' *' x ( $self->opt->all and $tags{$t} );
Condition33%1/3
$self->opt->all && $tags{$t}
!ll&&!rl&&r
300
MC/DC0%0/2
$self->opt->all && $tags{$t}
$self->opt->all $tags{$t}
Truth table33%1/3
A && B
A= $self->opt->allB= $tags{$t}
ABresult
0X0
100
111
60 }
61  
62 }
63  
64 1 ▶sub _remove_tags {
Subroutine _remove_tags: called CC=1 SCAR=0.0
65 1 my( $self, @tags ) = @_;
66  
67 1 $self->local_repo->remove_tags(@tags);
68  
69 1 $self->write_config;
70  
71 1 say "tags removed";
72 }
73  
74 16 1;
75  
76 __END__
« GitGot/Command/lib.pm ↑ Summary GitGot/Command/remove.pm »