| 1 | package App::PDRUtils::MultiCmd; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | our $DATE = '2021-05-25'; # DATE | |||||||||||||||||||||||||||
| 4 | 10 | our $VERSION = '0.122'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Log::ger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use App::PDRUtils::Cmd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use App::PDRUtils::DistIniCmd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use File::chdir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use Function::Fallback::CoreOrPP qw(clone); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use Perinci::Object; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 10 | our %common_args = ( | |||||||||||||||||||||||||||
| 18 | repos => { | ||||||||||||||||||||||||||||
| 19 | summary => '', | ||||||||||||||||||||||||||||
| 20 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 21 | 'x.name.singular' => 'repo', | ||||||||||||||||||||||||||||
| 22 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 23 | tags => ['common'], | ||||||||||||||||||||||||||||
| 24 | }, | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # XXX has_dist_ini filter option | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | depends => { | ||||||||||||||||||||||||||||
| 29 | summary => 'Only include repos that has prereq to specified module(s)', | ||||||||||||||||||||||||||||
| 30 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 31 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | doesnt_depend => { | ||||||||||||||||||||||||||||
| 35 | summary => 'Exclude repos that has prereq to specified module(s)', | ||||||||||||||||||||||||||||
| 36 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 37 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 38 | }, | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | include_dists => { | ||||||||||||||||||||||||||||
| 41 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 42 | 'x.name.singular' => 'include_dist', | ||||||||||||||||||||||||||||
| 43 | summary => 'Only include repos which have specified name(s)', | ||||||||||||||||||||||||||||
| 44 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 45 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||||||||
| 47 | exclude_dists => { | ||||||||||||||||||||||||||||
| 48 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 49 | 'x.name.singular' => 'exclude_dist', | ||||||||||||||||||||||||||||
| 50 | summary => 'Exclude repos which have specified name(s)', | ||||||||||||||||||||||||||||
| 51 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 52 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||
| 54 | include_dist_patterns => { | ||||||||||||||||||||||||||||
| 55 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 56 | 'x.name.singular' => 'include_dist_pattern', | ||||||||||||||||||||||||||||
| 57 | summary => 'Only include repos which match specified pattern(s)', | ||||||||||||||||||||||||||||
| 58 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 59 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||
| 61 | exclude_dist_patterns => { | ||||||||||||||||||||||||||||
| 62 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 63 | 'x.name.singular' => 'exclude_dist_pattern', | ||||||||||||||||||||||||||||
| 64 | summary => 'Exclude repos which match specified pattern(s)', | ||||||||||||||||||||||||||||
| 65 | schema => ['array*', of=>'str*'], | ||||||||||||||||||||||||||||
| 66 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 67 | }, | ||||||||||||||||||||||||||||
| 68 | has_tags => { | ||||||||||||||||||||||||||||
| 69 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 70 | 'x.name.singular' => 'has_tag', | ||||||||||||||||||||||||||||
| 71 | summary => 'Only include repos which have specified tag(s)', | ||||||||||||||||||||||||||||
| 72 | description => <<'_', | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | A repo can be tagged by tag `X` if it has a top-level file named `.tag-X`. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | _ | ||||||||||||||||||||||||||||
| 77 | schema => ['array*', of=>['str*'=>match=>qr/\A[A-Za-z0-9_-]+\z/]], | ||||||||||||||||||||||||||||
| 78 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 79 | }, | ||||||||||||||||||||||||||||
| 80 | lacks_tags => { | ||||||||||||||||||||||||||||
| 81 | 'x.name.is_plural' => 1, | ||||||||||||||||||||||||||||
| 82 | 'x.name.singular' => 'lacks_tag', | ||||||||||||||||||||||||||||
| 83 | summary => 'Exclude repos which have specified tag(s)', | ||||||||||||||||||||||||||||
| 84 | description => <<'_', | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | A repo can be tagged by tag `X` if it has a top-level file named `.tag-X`. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | _ | ||||||||||||||||||||||||||||
| 89 | schema => ['array*', of=>['str*'=>match=>qr/\A[A-Za-z0-9_-]+\z/]], | ||||||||||||||||||||||||||||
| 90 | tags => ['common', 'category:fitering'], | ||||||||||||||||||||||||||||
| 91 | }, | ||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub _ciod { | ||||||||||||||||||||||||||
|
Subroutine
_ciod: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 95 | 0 | state $ciod = do { | |||||||||||||||||||||||||||
| 96 | 0 | require Config::IOD; | |||||||||||||||||||||||||||
| 97 | 0 | Config::IOD->new( | |||||||||||||||||||||||||||
| 98 | ignore_unknown_directive => 1, | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | }; | ||||||||||||||||||||||||||||
| 101 | 0 | $ciod; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub _for_each_repo { | ||||||||||||||||||||||||||
|
Subroutine
_for_each_repo: not called CC=49 SCAR=78.0
| |||||||||||||||||||||||||||||
| 105 | 0 | require File::Slurper; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | my ($opts, $pargs, $callback) = @_; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $opts //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table0%0/2
A
A= $opts
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | local $CWD = $CWD; | |||||||||||||||||||||||||||
| 112 | 0 | my $envres = envresmulti(); | |||||||||||||||||||||||||||
| 113 | REPO: | ||||||||||||||||||||||||||||
| 114 | 0 | for my $repo (@{ $pargs->{repos} }) { | |||||||||||||||||||||||||||
| 115 | 0 | log_trace("Processing repo %s ...", $repo); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | eval { $CWD = $repo }; | |||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 0 | log_warn("Can't cd to repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 120 | 0 | $envres->add_result(500, "Can't cd to repo", {item_id=>$repo}); | |||||||||||||||||||||||||||
| 121 | 0 | next REPO; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | my $requires_parsed_dist_ini = $opts->{requires_parsed_dist_ini} // | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | (grep {defined($pargs->{$_})} qw/ | ||||||||||||||||||||||||||
|
Condition0%0/3
$opts->{"requires_parsed_dist_ini"} // grep({defined $pargs->{$_};} "depends", "doesnt_depend", "include_dists", "exclude_dists", "include_dist_patterns", "exclude_dist_patterns")
MC/DC0%0/2
$opts->{"requires_parsed_dist_ini"} // grep({defined $pargs->{$_};} "depends", "doesnt_depend", "include_dists", "exclude_dists", "include_dist_patterns", "exclude_dist_patterns")
$opts->{"requires_parsed_dist_ini"}
grep({defined $pargs->{$_};} "depends", "doesnt_depend", "include_dists", "exclude_dists", "include_dist_patterns", "exclude_dist_patterns")
Truth table0%0/3
A // B
A= $opts->{"requires_parsed_dist_ini"}B= grep({defined $pargs->{$_};} "depends", "doesnt_depend", "include_dists", "exclude_dists", "include_dist_patterns", "exclude_dist_patterns")
| |||||||||||||||||||||||||||||
| 126 | depends doesnt_depend | ||||||||||||||||||||||||||||
| 127 | include_dists exclude_dists | ||||||||||||||||||||||||||||
| 128 | include_dist_patterns exclude_dist_patterns | ||||||||||||||||||||||||||||
| 129 | /); | ||||||||||||||||||||||||||||
| 130 | 0 | my $requires_dist_ini = $opts->{requires_dist_ini}; | |||||||||||||||||||||||||||
| 131 | 0 | ▶ | $requires_dist_ini ||= $requires_parsed_dist_ini; | ||||||||||||||||||||||||||
|
Condition0%0/3
$requires_dist_ini ||= $requires_parsed_dist_ini
MC/DC0%0/2
$requires_dist_ini ||= $requires_parsed_dist_ini
$requires_dist_ini
$requires_parsed_dist_ini
Truth table0%0/3
A ||= B
A= $requires_dist_iniB= $requires_parsed_dist_ini
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my $dist_ini; | |||||||||||||||||||||||||||
| 134 | my $parsed_dist_ini; | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($requires_dist_ini) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | unless (-f "dist.ini") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | log_warn("No dist.ini in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 139 | 0 | $envres->add_result(412, "No dist.ini in repo", {item_id=>$repo}); | |||||||||||||||||||||||||||
| 140 | 0 | next REPO; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | 0 | $dist_ini = File::Slurper::read_text("dist.ini"); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($requires_parsed_dist_ini) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | eval { $parsed_dist_ini = _ciod->read_string($dist_ini) }; | |||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | log_warn("Can't parse dist.ini in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 149 | 0 | $envres->add_result(412, "Can't parse dist.ini: $@"); | |||||||||||||||||||||||||||
| 150 | 0 | next REPO; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my $excluded; | |||||||||||||||||||||||||||
| 155 | 0 | my $dist_name = $parsed_dist_ini->get_value("GLOBAL", "name"); | |||||||||||||||||||||||||||
| 156 | FILTER: | ||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||
| 158 | 0 | INCLUDE_DISTS: | |||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | last unless $pargs->{include_dists} && @{ $pargs->{include_dists} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"include_dists"} and @{$pargs->{"include_dists"};}
MC/DC0%0/2
$pargs->{"include_dists"} and @{$pargs->{"include_dists"};}
$pargs->{"include_dists"}
@{$pargs->{"include_dists"};}
Truth table0%0/3
A and B
A= $pargs->{"include_dists"}B= @{$pargs->{"include_dists"};}
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | unless (defined $dist_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | log_warn("Dist name undefined in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 163 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 164 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | 0 | for my $d (@{ $pargs->{include_dists} }) { | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | if ($dist_name eq $d) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | last INCLUDE_DISTS; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 0 | log_trace("Skipping repo (not in include_dists)"); | |||||||||||||||||||||||||||
| 172 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 173 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | EXCLUDE_DISTS: | ||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | last unless $pargs->{exclude_dists} && @{ $pargs->{exclude_dists} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"exclude_dists"} and @{$pargs->{"exclude_dists"};}
MC/DC0%0/2
$pargs->{"exclude_dists"} and @{$pargs->{"exclude_dists"};}
$pargs->{"exclude_dists"}
@{$pargs->{"exclude_dists"};}
Truth table0%0/3
A and B
A= $pargs->{"exclude_dists"}B= @{$pargs->{"exclude_dists"};}
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | unless (defined $dist_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | log_warn("Dist name undefined in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 180 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 181 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 0 | for my $d (@{ $pargs->{exclude_dists} }) { | |||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($dist_name eq $d) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | log_trace("Skipping repo (in exclude_dists)"); | |||||||||||||||||||||||||||
| 186 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 187 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | INCLUDE_DIST_PATTERNS: | ||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||
| 193 | 0 | ▶ | last unless $pargs->{include_dist_patterns} && @{ $pargs->{include_dist_patterns} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"include_dist_patterns"} and @{$pargs->{"include_dist_patterns"};}
MC/DC0%0/2
$pargs->{"include_dist_patterns"} and @{$pargs->{"include_dist_patterns"};}
$pargs->{"include_dist_patterns"}
@{$pargs->{"include_dist_patterns"};}
Truth table0%0/3
A and B
A= $pargs->{"include_dist_patterns"}B= @{$pargs->{"include_dist_patterns"};}
| |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | unless (defined $dist_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | log_warn("Dist name undefined in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 196 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 197 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 0 | for my $d (@{ $pargs->{include_dist_patterns} }) { | |||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($dist_name =~ /$d/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | last INCLUDE_DIST_PATTERNS; | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | 0 | log_trace("Skipping repo (doesn't match include_dist_patterns)"); | |||||||||||||||||||||||||||
| 205 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 206 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | EXCLUDE_DIST_PATTERNS: | ||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||
| 210 | 0 | ▶ | last unless $pargs->{exclude_dist_patterns} && @{ $pargs->{exclude_dist_patterns} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"exclude_dist_patterns"} and @{$pargs->{"exclude_dist_patterns"};}
MC/DC0%0/2
$pargs->{"exclude_dist_patterns"} and @{$pargs->{"exclude_dist_patterns"};}
$pargs->{"exclude_dist_patterns"}
@{$pargs->{"exclude_dist_patterns"};}
Truth table0%0/3
A and B
A= $pargs->{"exclude_dist_patterns"}B= @{$pargs->{"exclude_dist_patterns"};}
| |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | unless (defined $dist_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | log_warn("Dist name undefined in repo %s, skipped", $repo); | |||||||||||||||||||||||||||
| 213 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 214 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | 0 | for my $d (@{ $pargs->{exclude_dist_patterns} }) { | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($dist_name =~ /$d/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | log_trace("Skipping repo (match exclude_dist_patterns)"); | |||||||||||||||||||||||||||
| 219 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 220 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | DEPENDS: | ||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||
| 226 | 0 | my $mods = $pargs->{depends}; | |||||||||||||||||||||||||||
| 227 | 0 | ▶ | last unless $mods && @$mods; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mods and @$mods
MC/DC0%0/2
$mods and @$mods
$mods
@$mods
Truth table0%0/3
A and B
A= $modsB= @$mods
| |||||||||||||||||||||||||||||
| 228 | 0 | for my $mod (@$mods) { | |||||||||||||||||||||||||||
| 229 | 0 | ▶ | if (App::PDRUtils::Cmd::_has_prereq($parsed_dist_ini, $mod)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | last DEPENDS; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 0 | log_trace("Skipping repo %s (doesn't depend on ".join("/", @$mods).")", $repo); | |||||||||||||||||||||||||||
| 234 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 235 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | DOESNT_DEPEND: | ||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||
| 239 | 0 | my $mods = $pargs->{doesnt_depend}; | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | last unless $mods && @$mods; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mods and @$mods
MC/DC0%0/2
$mods and @$mods
$mods
@$mods
Truth table0%0/3
A and B
A= $modsB= @$mods
| |||||||||||||||||||||||||||||
| 241 | 0 | for my $mod (@$mods) { | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | if (App::PDRUtils::Cmd::_has_prereq($parsed_dist_ini, $mod)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | log_trace("Skipping repo %s (depends on $mod)", $repo); | |||||||||||||||||||||||||||
| 244 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 245 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | HAS_TAGS: | ||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | last unless $pargs->{has_tags} && @{ $pargs->{has_tags} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"has_tags"} and @{$pargs->{"has_tags"};}
MC/DC0%0/2
$pargs->{"has_tags"} and @{$pargs->{"has_tags"};}
$pargs->{"has_tags"}
@{$pargs->{"has_tags"};}
Truth table0%0/3
A and B
A= $pargs->{"has_tags"}B= @{$pargs->{"has_tags"};}
| |||||||||||||||||||||||||||||
| 252 | 0 | for my $t (@{ $pargs->{has_tags} }) { | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (-f ".tag-$t") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | last HAS_TAGS; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | 0 | log_trace("Skipping repo (doesn't have any tag in has_tags)"); | |||||||||||||||||||||||||||
| 258 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 259 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | LACKS_TAGS: | ||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||
| 263 | 0 | ▶ | last unless $pargs->{lacks_tags} && @{ $pargs->{lacks_tags} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pargs->{"lacks_tags"} and @{$pargs->{"lacks_tags"};}
MC/DC0%0/2
$pargs->{"lacks_tags"} and @{$pargs->{"lacks_tags"};}
$pargs->{"lacks_tags"}
@{$pargs->{"lacks_tags"};}
Truth table0%0/3
A and B
A= $pargs->{"lacks_tags"}B= @{$pargs->{"lacks_tags"};}
| |||||||||||||||||||||||||||||
| 264 | 0 | for my $t (@{ $pargs->{lacks_tags} }) { | |||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (-f ".tag-$t") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | log_trace("Skipping repo (has tag '$t' in lacks_tags)"); | |||||||||||||||||||||||||||
| 267 | 0 | $excluded++; | |||||||||||||||||||||||||||
| 268 | 0 | last FILTER; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | 0 | ▶ | next REPO if $excluded; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | my $res = $callback->( | |||||||||||||||||||||||||||
| 276 | parent_args => $pargs, | ||||||||||||||||||||||||||||
| 277 | repo => $repo, | ||||||||||||||||||||||||||||
| 278 | (dist => $dist_name) x !!defined($dist_name), | ||||||||||||||||||||||||||||
| 279 | (dist_ini => $dist_ini) x !!defined($dist_ini), | ||||||||||||||||||||||||||||
| 280 | (parsed_dist_ini => $parsed_dist_ini) x !!defined($parsed_dist_ini), | ||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||
| 282 | 0 | log_trace("Result for repo '%s': %s", $repo, $res); | |||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ($res->[0] != 200 && $res->[0] != 304) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->[0] != 200 and $res->[0] != 304
MC/DC0%0/2
$res->[0] != 200 and $res->[0] != 304
$res->[0] != 200
$res->[0] != 304
Truth table0%0/3
A and B
A= $res->[0] != 200B= $res->[0] != 304
| |||||||||||||||||||||||||||||
| 284 | 0 | log_warn("Processing repo %s failed: %s", $repo, $res); | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | 0 | $envres->add_result(@$res, {item_id=>$repo}); | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | 0 | $envres->as_struct; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 8 | ▶ | sub create_cmd_from_dist_ini_cmd { | ||||||||||||||||||||||||||
|
Subroutine
create_cmd_from_dist_ini_cmd: called CC=4 SCAR=19.0
Pod
documented
| |||||||||||||||||||||||||||||
| 292 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 8 | my %cargs = @_; | |||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 8 | my $name = $cargs{dist_ini_cmd}; | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 8 | my $source_pkg = "App::PDRUtils::DistIniCmd::$name"; | |||||||||||||||||||||||||||
| 299 | 8 | my $target_pkg = caller();#"App::PDRUtils::MultiCmd::$name"; | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 8 | ▶ | eval "use $source_pkg"; die if $@; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 8 | my $source_specs = \%{"$source_pkg\::SPEC"}; | |||||||||||||||||||||||||||
| 304 | 8 | my $spec = clone($source_specs->{handle_cmd}); | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 8 | for (keys %App::PDRUtils::DistIniCmd::common_args) { | |||||||||||||||||||||||||||
| 307 | 8 | delete $spec->{args}{$_}; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | 8 | for (keys %common_args) { | |||||||||||||||||||||||||||
| 310 | 72 | $spec->{args}{$_} = $common_args{$_}; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | 8 | $spec->{features}{dry_run} = 1; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 8 | ${"$target_pkg\::SPEC"}{handle_cmd} = $spec; | |||||||||||||||||||||||||||
| 315 | 8 | ▶ | *{"$target_pkg\::handle_cmd"} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.5
| |||||||||||||||||||||||||||||
| 316 | 0 | my %fargs = @_; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | _for_each_repo( | ||||||||||||||||||||||||||||
| 319 | {requires_parsed_dist_ini => 1}, | ||||||||||||||||||||||||||||
| 320 | \%fargs, | ||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 322 | 0 | my %cbargs = @_; | |||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 0 | my $repo = $cbargs{repo}; | |||||||||||||||||||||||||||
| 325 | 0 | my $dist = $cbargs{dist}; | |||||||||||||||||||||||||||
| 326 | 0 | my $pargs = $cbargs{parent_args}; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | my %diargs; | |||||||||||||||||||||||||||
| 329 | 0 | $diargs{parsed_dist_ini} = $cbargs{parsed_dist_ini}; | |||||||||||||||||||||||||||
| 330 | 0 | for (keys %{$spec->{args}}) { | |||||||||||||||||||||||||||
| 331 | 0 | ▶ | $diargs{$_} = $pargs->{$_} if exists $pargs->{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | my $handle_cmd = \&{"$source_pkg\::handle_cmd"}; | |||||||||||||||||||||||||||
| 335 | 0 | my $res = $handle_cmd->(%diargs); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ($res->[0] == 200) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 338 | log_info("%s[dist %s] %s", | ||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $fargs{-dry_run} ? "[DRY-RUN] " : "", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | $dist, | ||||||||||||||||||||||||||||
| 341 | $res->[1]); | ||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($fargs{-dry_run}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | 0 | $res->[0] = 304; | |||||||||||||||||||||||||||
| 344 | } else { | ||||||||||||||||||||||||||||
| 345 | 0 | File::Slurper::write_text( | |||||||||||||||||||||||||||
| 346 | "dist.ini", $res->[2]->as_string); | ||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | 0 | undef $res->[2]; | |||||||||||||||||||||||||||
| 349 | } else { | ||||||||||||||||||||||||||||
| 350 | 0 | log_trace("%d - %s", $res->[0], $res->[1]); | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | 0 | $res; | |||||||||||||||||||||||||||
| 353 | }, # callback | ||||||||||||||||||||||||||||
| 354 | 0 | ); # for each repo | |||||||||||||||||||||||||||
| 355 | 8 | }; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 10 | 1; | |||||||||||||||||||||||||||
| 359 | # ABSTRACT: Common stuffs for App::PDRUtils::MultiCmd::* | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | __END__ | ||||||||||||||||||||||||||||