| 1 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | package App::AYCABTU; | ||||||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use YAML::XS; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Capture::Tiny 'capture'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | has config => (is => 'ro', default => sub{[]}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 1 | has file => (is => 'ro', default => 'AYCABTU'); | |||||||||||||||||||||||||||||||
| 13 | 1 | has action => (is => 'ro', default => 'list'); | |||||||||||||||||||||||||||||||
| 14 | 1 | has show => (is => 'ro', default => ''); | |||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | has tags => (is => 'ro', default => sub{[]}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | has names => (is => 'ro', default => sub{[]}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 17 | 1 | has all => (is => 'ro', default => 0); | |||||||||||||||||||||||||||||||
| 18 | 1 | has quiet => (is => 'ro', default => 0); | |||||||||||||||||||||||||||||||
| 19 | 1 | has verbose => (is => 'ro', default => 0); | |||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | has args => (is => 'ro', default => sub{[]}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | has repos => (is => 'ro', default => sub{[]}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | my ($prefix, $error, $quiet, $normal, $verbose); | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 28 | my @opts = @_ | ||||||||||||||||||||||||||||||||
| 29 | ? @_ | ||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | : split /\s+/, ($ENV{AYCABTU_DEFAULT_OPTS} || ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$ENV{'AYCABTU_DEFAULT_OPTS'} || ''
MC/DC0%0/1
$ENV{'AYCABTU_DEFAULT_OPTS'} || ''
$ENV{'AYCABTU_DEFAULT_OPTS'}
Truth table0%0/2
A
A= $ENV{'AYCABTU_DEFAULT_OPTS'}
| |||||||||||||||||||||||||||||||||
| 31 | 0 | $self->get_options(@opts); | |||||||||||||||||||||||||||||||
| 32 | 0 | $self->read_config(); | |||||||||||||||||||||||||||||||
| 33 | 0 | $self->select_repos(); | |||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (not @{$self->repos} and not @{$self->names}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$self->repos;} or @{$self->names;}
MC/DC0%0/2
@{$self->repos;} or @{$self->names;}
@{$self->repos;}
@{$self->names;}
Truth table0%0/3
A or B
A= @{$self->repos;}B= @{$self->names;}
| |||||||||||||||||||||||||||||||||
| 35 | 0 | print "No repositories selected. Try --all.\n"; | |||||||||||||||||||||||||||||||
| 36 | 0 | return; | |||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | 0 | my $action = $self->action; | |||||||||||||||||||||||||||||||
| 39 | 0 | my $method = "action_$action"; | |||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | die "Can't perform action '$action'\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | unless $self->can($method); | ||||||||||||||||||||||||||||||||
| 42 | 0 | for my $entry (@{$self->repos}) { | |||||||||||||||||||||||||||||||
| 43 | 0 | ($prefix, $error, $quiet, $normal, $verbose) = ('') x 5; | |||||||||||||||||||||||||||||||
| 44 | 0 | $self->$method($entry); | |||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $verbose ||= $normal; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$verbose ||= $normal
MC/DC0%0/2
$verbose ||= $normal
$verbose
$normal
Truth table0%0/3
A ||= B
A= $verboseB= $normal
| |||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | $normal ||= $quiet; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$normal ||= $quiet
MC/DC0%0/2
$normal ||= $quiet
$normal
$quiet
Truth table0%0/3
A ||= B
A= $normalB= $quiet
| |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $msg = | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 48 | $error ? $error : | ||||||||||||||||||||||||||||||||
| 49 | $self->verbose ? $verbose : | ||||||||||||||||||||||||||||||||
| 50 | $self->quiet ? $quiet : | ||||||||||||||||||||||||||||||||
| 51 | $normal; | ||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $msg = "$prefix$msg\n" if $msg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 0 | print $msg; | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if (@{$self->names}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 0 | warn "The following names were not found: @{$self->names}\n"; | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub get_options { | ||||||||||||||||||||||||||||||
|
Subroutine
get_options: not called CC=6 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 62 | 0 | local @ARGV = @_; | |||||||||||||||||||||||||||||||
| 63 | GetOptions( | ||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | 'file=s' => sub { $self->file($_[1]) }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | 'verbose' => sub { $self->verbose(1) }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | 'quiet' => sub { $self->quiet(1) }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | 'list' => sub { $self->action('list') }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | 'update' => sub { $self->action('update') }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | 'status' => sub { $self->action('status') }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | 'show=s' => sub { $self->action('show'); $self->show($_[1]) }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | 'all' => sub { $self->all(1) }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | 'tags=s' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $tags = $_[1] or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | 0 | push @{$self->tags}, [split ',', $tags]; | |||||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||||||
| 76 | 0 | 'help' => \&help, | |||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 79 | 0 | my $names; | |||||||||||||||||||||||||||||||
| 80 | 0 | if (1 or not -t stdin) { | |||||||||||||||||||||||||||||||
| 81 | $names = [ | ||||||||||||||||||||||||||||||||
| 82 | map { | ||||||||||||||||||||||||||||||||
| 83 | 0 | s!/$!!; | |||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | /^(\d+)-(\d+)?$/ ? ($1..$2) : | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 85 | /^(\d+)$/ ? ($1) : | ||||||||||||||||||||||||||||||||
| 86 | (-d) ? ($_) : | ||||||||||||||||||||||||||||||||
| 87 | (); | ||||||||||||||||||||||||||||||||
| 88 | } @ARGV | ||||||||||||||||||||||||||||||||
| 89 | ]; | ||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | else { | ||||||||||||||||||||||||||||||||
| 92 | $names = [ split /\s+/, do {local $/; <stdin>} ] | ||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | 0 | $self->names($names); | |||||||||||||||||||||||||||||||
| 95 | 0 | die "Can't locate aycabtu config file '${\ $self->file}'. Use --file=... option\n" | |||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if not -e $self->file and not @{[glob $self->file . '*']}; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.9
Branch: 1 branch
Condition0%0/3
-e $self->file || @{[glob($self->file . '*')];}
MC/DC0%0/2
-e $self->file || @{[glob($self->file . '*')];}
-e $self->file
@{[glob($self->file . '*')];}
Truth table0%0/3
A || B
A= -e $self->fileB= @{[glob($self->file . '*')];}
| |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub read_yaml { | ||||||||||||||||||||||||||||||
|
Subroutine
read_yaml: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 101 | 0 | my @files = glob($self->file . '*'); | |||||||||||||||||||||||||||||||
| 102 | 0 | my $yaml = ''; | |||||||||||||||||||||||||||||||
| 103 | 0 | local $/; | |||||||||||||||||||||||||||||||
| 104 | 0 | for my $file (@files) { | |||||||||||||||||||||||||||||||
| 105 | 0 | open Y, $file; | |||||||||||||||||||||||||||||||
| 106 | 0 | $yaml .= <Y>; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | 0 | return $yaml; | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub read_config { | ||||||||||||||||||||||||||||||
|
Subroutine
read_config: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 112 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 113 | 0 | my $yaml = $self->read_yaml(); | |||||||||||||||||||||||||||||||
| 114 | 0 | my $config = YAML::XS::Load($yaml); | |||||||||||||||||||||||||||||||
| 115 | 0 | $self->config($config); | |||||||||||||||||||||||||||||||
| 116 | die $self->file . " must be a YAML sequence of mapping" | ||||||||||||||||||||||||||||||||
| 117 | if (ref($config) ne 'ARRAY') or grep { | ||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | ref ne 'HASH' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $config ne "ARRAY" or grep {ref $_ ne "HASH";} @$config
MC/DC0%0/2
ref $config ne "ARRAY" or grep {ref $_ ne "HASH";} @$config
ref $config ne "ARRAY"
grep {ref $_ ne "HASH";} @$config
Truth table0%0/3
A or B
A= ref $config ne "ARRAY"B= grep {ref $_ ne "HASH";} @$config
| |||||||||||||||||||||||||||||||||
| 119 | } @$config; | ||||||||||||||||||||||||||||||||
| 120 | 0 | my $count = 1; | |||||||||||||||||||||||||||||||
| 121 | 0 | for my $entry (@$config) { | |||||||||||||||||||||||||||||||
| 122 | my $repo = $entry->{repo} | ||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | or die "No 'repo' field for entry $count"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | $entry->{_num} = $count++; | |||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $entry->{name} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{"name"} ||= ""
MC/DC0%0/1
$entry->{"name"} ||= ""
$entry->{"name"}
Truth table0%0/2
A
A= $entry->{"name"}
| |||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if (not $entry->{name} and $repo =~ /.*\/(.*).git$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $entry->{"name"} and $repo =~ m[.*/(.*).git$]
MC/DC0%0/2
not $entry->{"name"} and $repo =~ m[.*/(.*).git$]
not $entry->{"name"}
$repo =~ m[.*/(.*).git$]
Truth table0%0/3
not(A) and B
A= not $entry->{"name"}B= $repo =~ m[.*/(.*).git$]
| |||||||||||||||||||||||||||||||||
| 129 | 0 | my $name = $1; | |||||||||||||||||||||||||||||||
| 130 | # XXX This should be configable. | ||||||||||||||||||||||||||||||||
| 131 | 0 | $name =~ s/\.wiki$/-wiki/; | |||||||||||||||||||||||||||||||
| 132 | 0 | $entry->{name} = $name; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $type = $entry->{type} || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{'type'} || ''
MC/DC0%0/1
$entry->{'type'} || ''
$entry->{'type'}
Truth table0%0/2
A
A= $entry->{'type'}
| |||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $type ||= | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$type ||= $repo =~ /\.git$/ ? "git" : ($repo =~ /svn/ ? "svn" : "")
MC/DC0%0/2
$type ||= $repo =~ /\.git$/ ? "git" : ($repo =~ /svn/ ? "svn" : "")
$type
$repo =~ /\.git$/ ? "git" : ($repo =~ /svn/ ? "svn" : "")
Truth table0%0/3
A ||= B
A= $typeB= $repo =~ /\.git$/ ? "git" : ($repo =~ /svn/ ? "svn" : "")
| |||||||||||||||||||||||||||||||||
| 137 | ($repo =~ /\.git$/) ? 'git' : | ||||||||||||||||||||||||||||||||
| 138 | ($repo =~ /svn/) ? 'svn' : | ||||||||||||||||||||||||||||||||
| 139 | ''; | ||||||||||||||||||||||||||||||||
| 140 | 0 | $entry->{type} = $type; | |||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | my $tags = $entry->{tags} || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{'tags'} || ''
MC/DC0%0/1
$entry->{'tags'} || ''
$entry->{'tags'}
Truth table0%0/2
A
A= $entry->{'tags'}
| |||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $set = $tags ? { map {($_, 1)} split /[\s\,]+/, $tags } : {}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 0 | my $str = $repo; | |||||||||||||||||||||||||||||||
| 146 | 0 | $str =~ s/\/$//; | |||||||||||||||||||||||||||||||
| 147 | 0 | $str =~ s/\/trunk$//; | |||||||||||||||||||||||||||||||
| 148 | 0 | $str =~ s/.*\///; | |||||||||||||||||||||||||||||||
| 149 | 0 | my $subst = { | |||||||||||||||||||||||||||||||
| 150 | py => 'python', | ||||||||||||||||||||||||||||||||
| 151 | pm => 'perl', | ||||||||||||||||||||||||||||||||
| 152 | }; | ||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $set->{$_} = 1 for map {$subst->{$_} || $_} split /[^\w]+/, $str; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$subst->{$_} || $_
MC/DC0%0/2
$subst->{$_} || $_
$subst->{$_}
$_
Truth table0%0/3
A || B
A= $subst->{$_}B= $_
| |||||||||||||||||||||||||||||||||
| 154 | 0 | $set->{$type} = 1; | |||||||||||||||||||||||||||||||
| 155 | 0 | delete $set->{''}; | |||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | 0 | $entry->{tags} = [ sort map lc, keys %$set ]; | |||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub select_repos { | ||||||||||||||||||||||||||||||
|
Subroutine
select_repos: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 162 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 0 | my $config = $self->config; | |||||||||||||||||||||||||||||||
| 165 | 0 | my $repos = $self->repos; | |||||||||||||||||||||||||||||||
| 166 | 0 | my $names = $self->names; | |||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 0 | my $last = 0; | |||||||||||||||||||||||||||||||
| 169 | OUTER: | ||||||||||||||||||||||||||||||||
| 170 | 0 | for my $entry (@$config) { | |||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | last if $last; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | next if $entry->{skip}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $last = 1 if $entry->{last}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($self->all) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 176 | 0 | push @$repos, $entry; | |||||||||||||||||||||||||||||||
| 177 | 0 | next; | |||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||
| 179 | 0 | my ($num, $name) = @{$entry}{qw(_num name)}; | |||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (@$names) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if (grep {$_ eq $name or $_ eq $num} @$names) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq $name || $_ eq $num
MC/DC0%0/2
$_ eq $name || $_ eq $num
$_ eq $name
$_ eq $num
Truth table0%0/3
A || B
A= $_ eq $nameB= $_ eq $num
| |||||||||||||||||||||||||||||||||
| 182 | 0 | push @$repos, $entry; | |||||||||||||||||||||||||||||||
| 183 | 0 | @$names = grep {$_ !~ /^(\Q$name\E|$num)$/} @$names; | |||||||||||||||||||||||||||||||
| 184 | 0 | next; | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | 0 | for my $tags (@{$self->tags}) { | |||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($tags) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 189 | my $count = scalar grep { | ||||||||||||||||||||||||||||||||
| 190 | 0 | my $t = $_; | |||||||||||||||||||||||||||||||
| 191 | 0 | grep {$_ eq $t} @{$entry->{tags}}; | |||||||||||||||||||||||||||||||
| 192 | } @$tags; | ||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($count == @$tags) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 194 | 0 | push @$repos, $entry; | |||||||||||||||||||||||||||||||
| 195 | 0 | next OUTER; | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub action_update { | ||||||||||||||||||||||||||||||
|
Subroutine
action_update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 204 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $self->_check(update => $entry) or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 0 | my ($num, $name) = @{$entry}{qw(_num name)}; | |||||||||||||||||||||||||||||||
| 207 | 0 | $prefix = "$num) Updating $name... "; | |||||||||||||||||||||||||||||||
| 208 | 0 | $self->git_update($entry); | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub action_status { | ||||||||||||||||||||||||||||||
|
Subroutine
action_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 213 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $self->_check('check status' => $entry) or return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | 0 | my ($num, $name) = @{$entry}{qw(_num name)}; | |||||||||||||||||||||||||||||||
| 216 | 0 | $prefix = "$num) Status for $name... "; | |||||||||||||||||||||||||||||||
| 217 | 0 | $self->git_status($entry); | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub action_list { | ||||||||||||||||||||||||||||||
|
Subroutine
action_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 222 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 223 | 0 | my ($num, $repo, $name, $type, $tags) = @{$entry}{qw(_num repo name type tags)}; | |||||||||||||||||||||||||||||||
| 224 | 0 | $prefix = "$num) "; | |||||||||||||||||||||||||||||||
| 225 | 0 | $quiet = $name; | |||||||||||||||||||||||||||||||
| 226 | 0 | $normal = sprintf " %-25s %-4s %-50s", $name, $type, $repo; | |||||||||||||||||||||||||||||||
| 227 | 0 | $verbose = "$normal\n tags: @$tags"; | |||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub action_show { | ||||||||||||||||||||||||||||||
|
Subroutine
action_show: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 231 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 232 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 233 | 0 | my $show = $self->show; | |||||||||||||||||||||||||||||||
| 234 | 0 | $prefix = ''; | |||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ($show =~ /^(nums?|numbers?)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 236 | 0 | $quiet = $entry->{_num}; | |||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||
| 238 | elsif ($show =~ /^names?$/) { | ||||||||||||||||||||||||||||||||
| 239 | 0 | $quiet = $entry->{name}; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | elsif ($show =~ /^tags?$/) { | ||||||||||||||||||||||||||||||||
| 242 | 0 | my $set = {}; | |||||||||||||||||||||||||||||||
| 243 | 0 | for my $repo (@{$self->repos}) { | |||||||||||||||||||||||||||||||
| 244 | 0 | $set->{$_} = 1 for @{$repo->{tags}}; | |||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||
| 246 | 0 | my @tags = sort keys %$set; | |||||||||||||||||||||||||||||||
| 247 | 0 | print "@tags\n"; | |||||||||||||||||||||||||||||||
| 248 | 0 | exit; | |||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||
| 250 | else { | ||||||||||||||||||||||||||||||||
| 251 | 0 | $error = "Invalid type '$show' to show."; | |||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub _check { | ||||||||||||||||||||||||||||||
|
Subroutine
_check: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 256 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 257 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||
| 258 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 259 | 0 | my ($num, $repo, $name, $type) = @{$entry}{qw(_num repo name type)}; | |||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if (not $name) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 261 | 0 | $error = "Can't $action $repo. No name."; | |||||||||||||||||||||||||||||||
| 262 | 0 | return; | |||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if (not $type) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 265 | 0 | $error = "Can't $action $name. Unknown type."; | |||||||||||||||||||||||||||||||
| 266 | 0 | return; | |||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($type ne 'git') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 269 | 0 | $error = "Can't $action $name. Type $type not yet supported."; | |||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub git_update { | ||||||||||||||||||||||||||||||
|
Subroutine
git_update: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 276 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 277 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 278 | 0 | my ($repo, $name) = @{$entry}{qw(repo name)}; | |||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if (not -d $name) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 280 | 0 | my $cmd = "git clone $repo $name"; | |||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | my ($o, $e) = capture { system($cmd) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($e =~ /\S/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 283 | 0 | $quiet = 'Error'; | |||||||||||||||||||||||||||||||
| 284 | 0 | $verbose = "\n$o$e"; | |||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||
| 286 | else { | ||||||||||||||||||||||||||||||||
| 287 | 0 | $normal = 'Done'; | |||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||
| 290 | elsif (-d "$name/.git") { | ||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my ($o, $e) = capture { system("cd $name; git pull origin master") }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ($o eq "Already up-to-date.\n") { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 293 | 0 | $normal = "Already up to date"; | |||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||
| 295 | elsif ($e) { | ||||||||||||||||||||||||||||||||
| 296 | 0 | $quiet = "Failed"; | |||||||||||||||||||||||||||||||
| 297 | 0 | $verbose = "\n$o$e"; | |||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||
| 299 | else { | ||||||||||||||||||||||||||||||||
| 300 | 0 | $quiet = "Updated"; | |||||||||||||||||||||||||||||||
| 301 | 0 | $verbose = "\n$o$e"; | |||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||
| 304 | else { | ||||||||||||||||||||||||||||||||
| 305 | 0 | $quiet = "Skipped"; | |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub git_status { | ||||||||||||||||||||||||||||||
|
Subroutine
git_status: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 310 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 311 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||
| 312 | 0 | my ($repo, $name) = @{$entry}{qw(repo name)}; | |||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if (not -d $name) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 314 | 0 | $error = "No local repository"; | |||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||
| 316 | elsif (-d "$name/.git") { | ||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my ($o, $e) = capture { system("cd $name; git status") }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($o =~ /^nothing to commit/m and | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$o =~ /^nothing to commit/m and not $e
MC/DC0%0/2
$o =~ /^nothing to commit/m and not $e
$o =~ /^nothing to commit/m
not $e
Truth table0%0/3
A and not(B)
A= $o =~ /^nothing to commit/mB= not $e
| |||||||||||||||||||||||||||||||||
| 319 | not $e | ||||||||||||||||||||||||||||||||
| 320 | ) { | ||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ($o =~ /Your branch is ahead .* by (\d+) /) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 322 | 0 | $quiet = "Ahead by $1"; | |||||||||||||||||||||||||||||||
| 323 | 0 | $verbose = "\n$o$e"; | |||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||
| 325 | else { | ||||||||||||||||||||||||||||||||
| 326 | 0 | $normal = "OK"; | |||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | else { | ||||||||||||||||||||||||||||||||
| 330 | 0 | $quiet = "Dirty"; | |||||||||||||||||||||||||||||||
| 331 | 0 | $verbose = "\n$o$e"; | |||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||
| 334 | else { | ||||||||||||||||||||||||||||||||
| 335 | 0 | $quiet= "Skipped"; | |||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub help { | ||||||||||||||||||||||||||||||
|
Subroutine
help: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 340 | 0 | print <<'...'; | |||||||||||||||||||||||||||||||
| 341 | Usage: | ||||||||||||||||||||||||||||||||
| 342 | aycabtu [ options ] action selectors | ||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | Options: | ||||||||||||||||||||||||||||||||
| 345 | --file=file # aycabtu config file. Default: 'AYCABTU' | ||||||||||||||||||||||||||||||||
| 346 | --verbose # Show more information | ||||||||||||||||||||||||||||||||
| 347 | --quiet # Show less information | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | Action: | ||||||||||||||||||||||||||||||||
| 350 | --list # List the selected repos (default action) | ||||||||||||||||||||||||||||||||
| 351 | --update # Checkout or update the selected repos | ||||||||||||||||||||||||||||||||
| 352 | --status # Get status info on the selected repos | ||||||||||||||||||||||||||||||||
| 353 | --show=aspect # Show some aspect of the selected repos | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | Show Aspects: | ||||||||||||||||||||||||||||||||
| 356 | numbers # Show the numbers of the selected repos | ||||||||||||||||||||||||||||||||
| 357 | names # Show the numbers of the selected repos | ||||||||||||||||||||||||||||||||
| 358 | tags # Show ALL tags of selected repos | ||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||
| 360 | Selector: | ||||||||||||||||||||||||||||||||
| 361 | --all # Use all the repos in the config file | ||||||||||||||||||||||||||||||||
| 362 | --tags=tags # Select repos matching all the tags | ||||||||||||||||||||||||||||||||
| 363 | Can be used more than once | ||||||||||||||||||||||||||||||||
| 364 | names # A list of the names to to select. You can use | ||||||||||||||||||||||||||||||||
| 365 | # multiple names and file globbing, like this: | ||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | aycabtu --update foo-repo bar-*-repo | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | ... | ||||||||||||||||||||||||||||||||
| 370 | 0 | exit; | |||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | 1 | 1; | |||||||||||||||||||||||||||||||