« /usr/local/lib/perl5/site_perl/5.44.0/Sub/Quote.pm
↑ Summary
/usr/local/lib/perl5/site_perl/5.44.0/x86_64-linux/Class/XSAccessor.pm »
| 1 | package Skilletor::Resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: What each scope resolves to – a sync's steps 1–3, stopped before anything is built | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 400 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 400 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 400 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 400 | ▶ | use Skilletor::Backend; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 400 | ▶ | use Skilletor::Bundles qw( expand_bundle entry_miss match_entry matches_pattern same_identity ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 400 | ▶ | use Skilletor::Cache qw( cache_name git_identity ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 400 | ▶ | use Skilletor::Catalog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 400 | ▶ | use Skilletor::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 400 | ▶ | use Skilletor::Entry qw( WILDCARD name_key ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 400 | ▶ | use Skilletor::FSUtil qw( decode_utf8_lossy encode_text path_join same_path ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 400 | ▶ | use Skilletor::JSON qw( js_ordered js_stringify js_type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 400 | ▶ | use Skilletor::Lock qw( read_lock key_to_type_name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 400 | ▶ | use Skilletor::Source::Git; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 400 | ▶ | use Skilletor::Source::Url; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 400 | ▶ | use Skilletor::State; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 400 | ▶ | use Skilletor::Targets qw( default_markers detect_harnesses detect_project_harnesses select_targets ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 400 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 400 | our $VERSION = '0.008000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 400 | my %TYPE_DIR = ( skill => 'skills', agent => 'agents', rule => 'rules' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 400 | my %FETCH = map { $_ => 1 } qw( always missing never ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 400 | has home => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 400 | has project_dir => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # `CLAUDE_CONFIG_DIR` (k145): Claude Code's config dir, which is the user scope's `.claude` – | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # config, lock, state, roots – and where its plugin state lives. Empty means unset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | has claude_config_dir => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1417 | ▶ | builder => sub { defined $ENV{CLAUDE_CONFIG_DIR} ? decode_utf8_lossy( $ENV{CLAUDE_CONFIG_DIR} ) : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_claude_config_dir: called CC=2 SCAR=6.9
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | has state_root => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1333 | ▶ | builder => sub { Skilletor::State->default_root( $_[0]->home, $_[0]->claude_config_dir ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_state_root: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | has cache_root => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2417 | ▶ | builder => sub { path_join( $_[0]->state_root, 'cache' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_cache_root: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # `$CODEX_HOME`, for the harness markers; empty means unset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | has codex_home => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 398 | ▶ | builder => sub { defined $ENV{CODEX_HOME} ? decode_utf8_lossy( $ENV{CODEX_HOME} ) : undef }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_codex_home: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | has markers => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1622 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
Subroutine
_build_markers: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1622 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1622 | my $cx = $self->codex_home; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1622 | my $cd = $self->claude_config_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1622 | ▶ | return default_markers( $self->home, ( defined $cx && length $cx ) ? $cx : undef, ( defined $cd && length $cd ) ? $cd : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
defined $cx and length $cx
defined $cd and length $cd
MC/DC50%1/2
defined $cx and length $cx
defined $cx
length $cx
MC/DC100%2/2
defined $cd and length $cd
defined $cd
length $cd
Truth table66%2/3
A and B
A= defined $cxB= length $cx
Truth table100%3/3
A and B
A= defined $cdB= length $cd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | has require_harness => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4281 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | has fetch => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4281 | ▶ | default => sub { 'always' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4575 | ▶ | isa => sub { croak 'fetch must be always, missing or never' unless defined $_[0] && $FETCH{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
defined $_[0] and $FETCH{$_[0]}
MC/DC50%1/2
defined $_[0] and $FETCH{$_[0]}
defined $_[0]
$FETCH{$_[0]}
Truth table66%2/3
A and B
A= defined $_[0]B= $FETCH{$_[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 400 | has timeout_ms => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | has lock_timeout_ms => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4479 | ▶ | default => sub { 5_000 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 400 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 128 | ▶ | sub _message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 128 | my ( $err ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 128 | ▶ | return $err->message if blessed $err && $err->can('message'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($err) and $err->can("message")
MC/DC0%0/2
builtin::blessed($err) and $err->can("message")
builtin::blessed($err)
$err->can("message")
Truth table33%1/3
A and B
A= builtin::blessed($err)B= $err->can("message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return ( "$err" =~ s/ at \S+ line \d+\.?\n?\z//r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # The project dir, unless it is the home dir itself: then there is no project scope (spec §6.1). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 70763 | ▶ | sub project_dir_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
project_dir_of: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 70763 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 70763 | my $p = $self->project_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 70763 | ▶ | return undef if !defined $p || !length $p || same_path( $p, $self->home ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $p && length $p or same_path($p, $self->home)
defined $p && length $p
MC/DC66%2/3
not defined $p && length $p or same_path($p, $self->home)
defined $p
length $p
same_path($p, $self->home)
Truth table75%3/4
not(A && B) or C
A= defined $pB= length $pC= same_path($p, $self->home)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 70246 | return $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # Claude Code's config dir: the explicit one, else `<home>/.claude`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 32849 | ▶ | sub claude_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
claude_dir: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 32849 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 32849 | my $cd = $self->claude_config_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 32849 | ▶ | return ( defined $cd && length $cd ) ? $cd : path_join( $self->home, '.claude' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $cd and length $cd
MC/DC100%2/2
defined $cd and length $cd
defined $cd
length $cd
Truth table100%3/3
A and B
A= defined $cdB= length $cd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # The scope's `.claude` directory: config, lock and the claude target root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 35961 | ▶ | sub _target_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_target_dir: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 35961 | my ( $self, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 35961 | ▶ | return $scope eq 'user' ? $self->claude_dir : path_join( $self->_base_of($scope), '.claude' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 50022 | ▶ | sub _base_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_base_of: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 50022 | my ( $self, $scope ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 50022 | ▶ | return $scope eq 'user' ? $self->home : $self->project_dir_of; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Config and targets. A harness is only needed with require_harness (the reference's sync | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # needs one); without it a machine with none resolves all the same, with no targets warnings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 389 | ▶ | sub _load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 389 | my ( $self, $include_project ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 389 | ▶ | $include_project //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$include_project //= 1
MC/DC0%0/1
$include_project //= 1
$include_project
Truth table50%1/2
A
A= $include_project
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 389 | my $config = Skilletor::Config->load( home => $self->home, claude_config_dir => $self->claude_config_dir, project_dir => $self->project_dir_of ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 341 | my $markers = $self->markers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 341 | ▶ | my $wanted = { user => $config->user->{targets}, project => $config->project ? $config->project->{targets} : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 341 | ▶ | if ( $include_project && $config->project && !exists $config->project->{targets} && defined $self->project_dir_of ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$include_project and $config->project and not exists $config->project->{"targets"} and defined $self->project_dir_of
$include_project and $config->project and not exists $config->project->{"targets"}
$include_project and $config->project
MC/DC25%1/4
$include_project and $config->project and not exists $config->project->{"targets"} and defined $self->project_dir_of
$include_project
$config->project
not exists $config->project->{"targets"}
defined $self->project_dir_of
Truth table40%2/5
A and B and not(C) and D
A= $include_projectB= $config->projectC= not exists $config->project->{"targets"}D= defined $self->project_dir_of
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 121 | my $target_dir = $self->_target_dir('project'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 121 | my $lock_path = path_join( $target_dir, 'skilletor.lock.json' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 121 | my $in_use = grep { -e encode_text($_) } map { path_join( $target_dir, $_ ) } qw( skilletor.json skilletor.local.json skilletor.lock.json ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 121 | ▶ | $wanted->{project_evidence} = detect_project_harnesses( $self->project_dir_of, read_lock($lock_path) ) if $in_use; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 341 | my $targets = eval { select_targets( $wanted, detect_harnesses($markers), $markers ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 341 | ▶ | unless ($targets) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 261 | ▶ | die $@ if $self->require_harness; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 237 | $targets = { user => [], project => [], warnings => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 317 | return ( $config, $targets ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 389 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 389 | my ( $self, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 389 | ▶ | my $sel = $opts{scope} // 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"scope"} // "all"
MC/DC100%1/1
$opts{"scope"} // "all"
$opts{"scope"}
Truth table100%2/2
A
A= $opts{"scope"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 389 | ▶ | croak 'scope must be user, project or all' unless $sel =~ /\A(?:user|project|all)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 389 | my $state = Skilletor::State->new( root => $self->state_root, read_once => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | return $state->with_lock( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 389 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 389 | Skilletor::Source::Url->sweep_cache( $self->cache_root ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 389 | Skilletor::Source::Git->sweep_cache( $self->cache_root ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 389 | my ( $config, $targets ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 389 | ▶ | unless ( eval { ( $config, $targets ) = $self->_load( $sel ne 'user' ); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 72 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 72 | ▶ | die $err if $opts{throw}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 48 | return { scopes => [], error => _message($err) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 317 | my $run = {}; # each backend resolved once per run, for both scopes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 317 | my @scopes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 317 | ▶ | push @scopes, [ user => $config->user ] if $sel eq 'user' || $sel eq 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sel eq "user" or $sel eq "all"
MC/DC0%0/2
$sel eq "user" or $sel eq "all"
$sel eq "user"
$sel eq "all"
Truth table33%1/3
A or B
A= $sel eq "user"B= $sel eq "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 317 | ▶ | push @scopes, [ project => $config->project ] if ( $sel eq 'project' || $sel eq 'all' ) && $config->project; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$sel eq "project" || $sel eq "all" and $config->project
$sel eq "project" or $sel eq "all"
MC/DC33%1/3
$sel eq "project" || $sel eq "all" and $config->project
$sel eq "project"
$sel eq "all"
$config->project
Truth table40%2/5
A or B and C
A= $sel eq "project"B= $sel eq "all"C= $config->project
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 317 | my $out = { scopes => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 317 | for my $s (@scopes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 414 | my ( $scope, $scope_cfg ) = @$s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 414 | my $rep = $self->_resolve_scope( $config, $scope_cfg, $scope, $state, $run ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 391 | ▶ | unshift @{ $rep->{warnings} }, @{ $targets->{warnings} } if $scope eq 'project'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 391 | push @{ $out->{scopes} }, $rep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 294 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 389 | timeout_ms => $self->lock_timeout_ms, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # Every source a scope references, through explicit entries, wildcards or bundles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5399 | ▶ | sub _scope_sources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scope_sources: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5399 | my ( $scope_cfg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5399 | my ( %seen, @out ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5399 | for my $i ( @{ $scope_cfg->{install} }, @{ $scope_cfg->{wildcards} }, @{ $scope_cfg->{bundles} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6058 | ▶ | push @out, $i->{source} unless $seen{ $i->{source} }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5399 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 883 | ▶ | sub bundle_label { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bundle_label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 883 | my ( $class, $b ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 883 | return 'bundle:'.$b->{name}.'@'.$b->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # The configured source serving a bundle entry of another source (spec §15.6): the first, in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # config order, whose `git`/`url` identity is $url. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 602 | ▶ | sub _serving_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serving_source: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 602 | my ( $config, $scope, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 602 | for my $src ( @{ $config->sources_of($scope) } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1042 | ▶ | my $id = $src->{git} // $src->{url}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$src->{"git"} // $src->{"url"}
MC/DC50%1/2
$src->{"git"} // $src->{"url"}
$src->{"git"}
$src->{"url"}
Truth table66%2/3
A // B
A= $src->{"git"}B= $src->{"url"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1042 | ▶ | return $src->{name} if defined $id && same_identity( $id, $url ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $id and same_identity($id, $url)
MC/DC100%2/2
defined $id and same_identity($id, $url)
defined $id
same_identity($id, $url)
Truth table100%3/3
A and B
A= defined $idB= same_identity($id, $url)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 305 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # A backend through the run's one resolve of it, under the fetch policy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4880 | ▶ | sub _resolve_backend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_backend: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4880 | my ( $self, $run, $backend ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4880 | my $key = Skilletor::Backend->identity($backend); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 4880 | ▶ | $run->{$key} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$run->{$key} //= do {
my $loc;
eval {
do {
$loc = $self->_fetch($backend);
1
}
} ? {"ok", $loc} : {"err", $@}
}
MC/DC100%2/2
$run->{$key} //= do {
my $loc;
eval {
do {
$loc = $self->_fetch($backend);
1
}
} ? {"ok", $loc} : {"err", $@}
}
$run->{$key}
do {
my $loc;
eval {
do {
$loc = $self->_fetch($backend);
1
}
} ? {"ok", $loc} : {"err", $@}
}
Truth table100%3/3
A //= B
A= $run->{$key}B= do {
my $loc;
eval {
do {
$loc = $self->_fetch($backend);
1
}
} ? {"ok", $loc} : {"err", $@}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4274 | my $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 4274 | ▶ | eval { $loc = $self->_fetch($backend); 1 } ? { ok => $loc } : { err => $@ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4756 | ▶ | die $run->{$key}{err} if exists $run->{$key}{err}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4676 | return $run->{$key}{ok}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4274 | ▶ | sub _fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4274 | my ( $self, $backend ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4274 | my $src = Skilletor::Backend->make( $backend, $self->cache_root, $self->timeout_ms ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4274 | my $fetch = $self->fetch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4274 | ▶ | return $src->resolve if $fetch eq 'always' || $backend->{kind} eq 'local'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$fetch eq "always" or $backend->{"kind"} eq "local"
MC/DC50%1/2
$fetch eq "always" or $backend->{"kind"} eq "local"
$fetch eq "always"
$backend->{"kind"} eq "local"
Truth table66%2/3
A or B
A= $fetch eq "always"B= $backend->{"kind"} eq "local"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 119 | ▶ | return $src->cached if $fetch eq 'never'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 42 | my $loc = eval { $src->cached }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 40 | ▶ | return $loc if $loc && $loc->{version} ne 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$loc and $loc->{"version"} ne "unknown"
MC/DC50%1/2
$loc and $loc->{"version"} ne "unknown"
$loc
$loc->{"version"} ne "unknown"
Truth table66%2/3
A and B
A= $locB= $loc->{"version"} ne "unknown"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 24 | return $src->resolve; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1418 | ▶ | sub _item_vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_item_vars: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1418 | my ( @layers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1418 | my $out = js_ordered(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1418 | for my $l ( grep { defined } @layers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ( ref $l eq 'ARRAY' ) { $out->{$_} = $l->[$_] for 0 .. $#$l } # { ...array }: by index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1973 | else { $out->{$_} = $l->{$_} for keys %$l } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1418 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1233 | ▶ | sub _uniq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uniq: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1233 | my ( %seen, @out ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1233 | ▶ | for (@_) { push @out, $_ unless $seen{$_}++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1233 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 250 | ▶ | sub _str_eq { defined $_[0] && defined $_[1] && !ref $_[0] && $_[0] eq $_[1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_str_eq: called CC=4 SCAR=19.1
Branch: 1 branch
Condition33%2/6
defined $_[0] and defined $_[1] and not ref $_[0]
defined $_[0] and defined $_[1]
MC/DC0%0/3
defined $_[0] and defined $_[1] and not ref $_[0]
defined $_[0]
defined $_[1]
not ref $_[0]
Truth table25%1/4
A and B and not(C)
A= defined $_[0]B= defined $_[1]C= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # `entry.via?.includes(label)`: the array holds exactly the label (read_lock refuses any other `via`). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 258 | ▶ | sub _via_has { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_via_has: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 258 | my ( $via, $label ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 258 | ▶ | return 0 unless ref $via eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 238 | ▶ | return ( grep { _str_eq( $_, $label ) } @$via ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 411 | ▶ | sub _valid_item_name { $_[0] =~ /\A[A-Za-z0-9._\-]+\z/ ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_item_name: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # Bundle vars of one item from every chain it was reached through (spec §15.3): a key every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # setting chain agrees on applies; one set to different values applies from none. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 411 | ▶ | sub _merge_chain_vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_chain_vars: called CC=6 SCAR=27.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 411 | my ( $chains, $source, $conflict ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 411 | my ( %values, @order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 411 | for my $c (@$chains) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 236 | for my $key ( keys %{ $c->{vars} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $setter = __PACKAGE__->bundle_label( { name => $c->{setters}{$key}, source => $source } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | push @order, $key unless $values{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | push @{ $values{$key} }, { value => $c->{vars}{$key}, setter => $setter }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 411 | my $out = js_ordered(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 411 | for my $key (@order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $list = $values{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( _uniq( map { js_stringify( $_->{value} ) } @$list ) == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $out->{$key} = $list->[0]{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $conflict->( $key, [ _uniq( map { $_->{setter} } @$list ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 411 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # One scope, as the reference's syncScopeRun runs it: without $hooks with `collect` (the items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # into the report), with them for a sync (Skilletor::Engine) – `declare` sees each declared item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # before its lookup (false: no target gets it, nothing is looked up), `build` each one found, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # `keep` the target and type of each one a sync must leave as it is installed. In list context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # also what the sync needs of the run: { resolved, resolved_order, catalogs, served, old_lock }. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5399 | ▶ | sub _resolve_scope { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_scope: called CC=65 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 5399 | my ( $self, $config, $scope_cfg, $scope, $state, $run, $hooks ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5399 | ▶ | my $keep_if_locked = $hooks ? $hooks->{keep} : sub { }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 5399 | my $rep = { scope => $scope, warnings => [], trustRequests => [], items => [], sources => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 5399 | my $warnings = $rep->{warnings}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 5399 | my $target_dir = $self->_target_dir($scope); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5399 | my $old_lock = read_lock( path_join( $target_dir, 'skilletor.lock.json' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # Every needed source, trust checked and resolved against the one chosen backend. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5399 | my ( %resolved, @resolved_order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4905 | ▶ | my $set = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 4905 | my ( $name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4905 | ▶ | push @resolved_order, $name unless exists $resolved{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 4905 | $resolved{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5399 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 10715 | ▶ | my $resolve_all = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # The names not resolved yet, each once, decided up front, as the reference starts them all at once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 10715 | my %once; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 10715 | ▶ | for my $name ( grep { !exists $resolved{$_} && !$once{$_}++ } @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $resolved{$_} || $once{$_}++
MC/DC0%0/2
exists $resolved{$_} || $once{$_}++
exists $resolved{$_}
$once{$_}++
Truth table33%1/3
A || B
A= exists $resolved{$_}B= $once{$_}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5029 | my $src = $config->source_of( $scope, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 5029 | ▶ | unless ($src) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | push @$warnings, 'unknown source: '.$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $set->( $name, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 5029 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 5029 | my $backend = Skilletor::Backend->resolve( $src, $self->home ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 5029 | ▶ | if ( !$state->is_trusted( $name, $backend ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 149 | push @{ $rep->{trustRequests} }, Skilletor::Backend->trust_request( $name, $backend ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 149 | $set->( $name, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 149 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 4880 | my $loc = $self->_resolve_backend( $run, $backend ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # A shared resolve's warning (a fetch that fell back to the cache) is named once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | push @$warnings, $loc->{warning} if defined $loc->{warning} && !grep { $_ eq $loc->{warning} } @$warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $loc->{"warning"} and not grep({$_ eq $loc->{"warning"};} @$warnings)
MC/DC50%1/2
defined $loc->{"warning"} and not grep({$_ eq $loc->{"warning"};} @$warnings)
defined $loc->{"warning"}
not grep({$_ eq $loc->{"warning"};} @$warnings)
Truth table66%2/3
A and not(B)
A= defined $loc->{"warning"}B= not grep({$_ eq $loc->{"warning"};} @$warnings)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 4676 | $set->( $name, { dir => $loc->{dir}, version => $loc->{version}, backend => $backend } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 4676 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 4905 | ▶ | next if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 80 | push @$warnings, 'source '.$name.': '._message($@); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 80 | $set->( $name, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 5399 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5399 | $resolve_all->( _scope_sources($scope_cfg) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 5316 | my %catalogs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 6528 | ▶ | my $catalog_of = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 6528 | my ( $source ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 6528 | ▶ | return $catalogs{$source} if exists $catalogs{$source}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 4839 | my $r = $resolved{$source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 4839 | my $cat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4839 | ▶ | if ($r) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 4610 | $cat = eval { Skilletor::Catalog->scan( $r->{dir}, $r->{backend}{path} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 4610 | ▶ | push @$warnings, 'source '.$source.': '._message($@) unless $cat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 4839 | return $catalogs{$source} = $cat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 5316 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 5844 | ▶ | my $lookup = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 5844 | my ( $item ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 5844 | my $r = $resolved{ $item->{source} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 5844 | my $cat = $catalog_of->( $item->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 5844 | ▶ | unless ( $r && $cat ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$r and $cat
MC/DC50%1/2
$r and $cat
$r
$cat
Truth table66%2/3
A and B
A= $rB= $cat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 229 | $keep_if_locked->( $item->{target}, $item->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 229 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 5615 | ▶ | my ($ci) = grep { $_->{type} eq $item->{type} && $_->{name} eq $item->{name} } @{ $cat->{items} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->{'type'} eq $item->{'type'} && $_->{'name'} eq $item->{'name'}
MC/DC100%2/2
$_->{'type'} eq $item->{'type'} && $_->{'name'} eq $item->{'name'}
$_->{'type'} eq $item->{'type'}
$_->{'name'} eq $item->{'name'}
Truth table100%3/3
A && B
A= $_->{'type'} eq $item->{'type'}B= $_->{'name'} eq $item->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 5615 | ▶ | unless ($ci) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 43 | push @$warnings, 'item not found in source '.$item->{source}.': '.$item->{type}.' '.$item->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 43 | $keep_if_locked->( $item->{target}, $item->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 43 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 5572 | ▶ | if ( defined $ci->{error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # An error of the item itself (spec §4.1): it is not built, what it installed stays. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | push @$warnings, $item->{type}.' '.$item->{name}.'@'.$item->{source}.': '.$ci->{error}.'; an installed copy stays'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $keep_if_locked->( $item->{target}, $item->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5572 | return { r => $r, cat => $cat, item => $ci }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5316 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 5866 | ▶ | my $build_item = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 5866 | my ( $item, $extra ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 5866 | ▶ | if ($hooks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 4884 | ▶ | $hooks->{declare}->($item) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 4862 | ▶ | my $found = $lookup->($item) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 4639 | ▶ | $hooks->{build}->( $item, $extra // {}, $found, $warnings ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$extra // {}
MC/DC0%0/1
$extra // {}
$extra
Truth table50%1/2
A
A= $extra
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4638 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 982 | ▶ | my $found = $lookup->($item) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | my $ri = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | type => $item->{type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | name => $item->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | source => $item->{source}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | declaredBy => $extra->{declaredBy} // [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | sourceDir => $found->{r}{dir}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | item => $found->{item}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 933 | ▶ | vars => _item_vars( $found->{cat}{meta}{vars}, $extra->{bundleVars}, $scope_cfg->{vars} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$extra->{"declaredBy"} // []
MC/DC0%0/1
$extra->{"declaredBy"} // []
$extra->{"declaredBy"}
Truth table50%1/2
A
A= $extra->{"declaredBy"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 933 | ▶ | $ri->{via} = $extra->{via} if $extra->{via} && @{ $extra->{via} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$extra->{"via"} and @{$extra->{"via"};}
MC/DC0%0/2
$extra->{"via"} and @{$extra->{"via"};}
$extra->{"via"}
@{$extra->{"via"};}
Truth table33%1/3
A and B
A= $extra->{"via"}B= @{$extra->{"via"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 933 | push @{ $rep->{items} }, $ri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 5316 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # Wildcards and bundles as offers per target, by name ignoring case (k135). An unresolvable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # source (or a bundle that cannot be expanded) offers what it installed before. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 5316 | my ( %offers, @offer_order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 5316 | ▶ | my $target_key = sub { $TYPE_DIR{ $_[0] }.'/'.name_key( $_[1] ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 421 | ▶ | my $offer = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 421 | my ( $type, $name, $o ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 421 | my $key = $target_key->( $type, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 421 | ▶ | unless ( $offers{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 417 | $offers{$key} = { type => $type, offers => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 417 | push @offer_order, $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 421 | my $entry = $offers{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 421 | ▶ | push @{ $entry->{offers} }, { %$o, name => $name } unless grep { $_->{from} eq $o->{from} && $_->{name} eq $name } @{ $entry->{offers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_->{'from'} eq $o->{'from'} && $_->{'name'} eq $name
MC/DC0%0/2
$_->{'from'} eq $o->{'from'} && $_->{'name'} eq $name
$_->{'from'} eq $o->{'from'}
$_->{'name'} eq $name
Truth table33%1/3
A && B
A= $_->{'from'} eq $o->{'from'}B= $_->{'name'} eq $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 5316 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 5316 | my @locked = map { +{ %{ key_to_type_name($_) }, entry => $old_lock->{$_} } } keys %$old_lock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | my $entry_source = sub { my $e = $_[0]{entry}; return js_type($e) eq 'object' ? $e->{source} : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5316 | for my $w ( @{ $scope_cfg->{wildcards} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 123 | ▶ | if ( my $cat = $catalog_of->( $w->{source} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 123 | ▶ | my @hits = grep { $_->{type} eq $w->{type} && matches_pattern( $w->{pattern}, $_->{name} ) } @{ $cat->{items} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->{'type'} eq $w->{'type'} && matches_pattern($w->{'pattern'}, $_->{'name'})
MC/DC50%1/2
$_->{'type'} eq $w->{'type'} && matches_pattern($w->{'pattern'}, $_->{'name'})
$_->{'type'} eq $w->{'type'}
matches_pattern($w->{'pattern'}, $_->{'name'})
Truth table66%2/3
A && B
A= $_->{'type'} eq $w->{'type'}B= matches_pattern($w->{'pattern'}, $_->{'name'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # A bare `*` may legitimately match nothing (a source without rules): silent (spec §3). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 123 | ▶ | if ( !@hits && $w->{pattern} ne WILDCARD ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @hits and $w->{"pattern"} ne "*"
MC/DC0%0/2
not @hits and $w->{"pattern"} ne "*"
not @hits
$w->{"pattern"} ne "*"
Truth table33%1/3
not(A) and B
A= not @hitsB= $w->{"pattern"} ne "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | push @$warnings, $w->{type}.' wildcard '.$w->{raw}.' matches nothing in source '.$w->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 123 | $offer->( $w->{type}, $_->{name}, { from => $w->{raw}, source => $w->{source}, live => 1 } ) for @hits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | for my $l (@locked) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | next unless _str_eq( $entry_source->($l), $w->{source} ) && $l->{type} eq $w->{type} && matches_pattern( $w->{pattern}, $l->{name} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
_str_eq(&$entry_source($l), $w->{"source"}) and $l->{"type"} eq $w->{"type"} and matches_pattern($w->{"pattern"}, $l->{"name"})
_str_eq(&$entry_source($l), $w->{"source"}) and $l->{"type"} eq $w->{"type"}
MC/DC0%0/3
_str_eq(&$entry_source($l), $w->{"source"}) and $l->{"type"} eq $w->{"type"} and matches_pattern($w->{"pattern"}, $l->{"name"})
_str_eq(&$entry_source($l), $w->{"source"})
$l->{"type"} eq $w->{"type"}
matches_pattern($w->{"pattern"}, $l->{"name"})
Truth table0%0/4
A and B and C
A= _str_eq(&$entry_source($l), $w->{"source"})B= $l->{"type"} eq $w->{"type"}C= matches_pattern($w->{"pattern"}, $l->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $offer->( $l->{type}, $l->{name}, { from => $w->{raw}, source => $w->{source}, live => 0 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # Bundles: expanded against their own source first; entries of other sources (spec §15.6) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # are served by a configured source with the same identity, resolved next. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | my @expansions = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 333 | my $b = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 333 | my $label = __PACKAGE__->bundle_label($b); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 333 | my $cat = $catalog_of->( $b->{source} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 333 | my $expanded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 333 | ▶ | if ($cat) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 333 | ▶ | unless ( eval { $expanded = expand_bundle( $cat, $b->{name} ); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | die $err unless blessed $err && $err->isa('Skilletor::Error::Bundle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($err) and $err->isa("Skilletor::Error::Bundle")
MC/DC0%0/2
builtin::blessed($err) and $err->isa("Skilletor::Error::Bundle")
builtin::blessed($err)
$err->isa("Skilletor::Error::Bundle")
Truth table0%0/3
A and B
A= builtin::blessed($err)B= $err->isa("Skilletor::Error::Bundle")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | push @$warnings, $label.': '.$err->message.'; its installed items are kept'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 333 | ▶ | my @foreign = map { +{ f => $_, served => _serving_source( $config, $scope, $_->{url} ) } } @{ $expanded ? $expanded->{foreign} : [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 333 | +{ b => $b, label => $label, expanded => $expanded, foreign => \@foreign }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 5316 | } @{ $scope_cfg->{bundles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 5316 | ▶ | $resolve_all->( map { map { defined $_->{served} ? $_->{served} : () } @{ $_->{foreign} } } @expansions ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 5275 | for my $x (@expansions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 292 | my ( $b, $label, $expanded ) = @{$x}{qw( b label expanded )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 52 | ▶ | my $keep_from_lock = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 52 | my ( $match ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 52 | for my $l (@locked) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 6 | ▶ | next unless js_type( $l->{entry} ) eq 'object' && _via_has( $l->{entry}{via}, $label ) && $match->($l); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
js_type($l->{"entry"}) eq "object" and _via_has($l->{"entry"}{"via"}, $label) and &$match($l)
js_type($l->{"entry"}) eq "object" and _via_has($l->{"entry"}{"via"}, $label)
MC/DC0%0/3
js_type($l->{"entry"}) eq "object" and _via_has($l->{"entry"}{"via"}, $label) and &$match($l)
js_type($l->{"entry"}) eq "object"
_via_has($l->{"entry"}{"via"}, $label)
&$match($l)
Truth table25%1/4
A and B and C
A= js_type($l->{"entry"}) eq "object"B= _via_has($l->{"entry"}{"via"}, $label)C= &$match($l)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $offer->( $l->{type}, $l->{name}, { from => $label, source => $l->{entry}{source}, live => 0, via => $label } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 292 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 292 | ▶ | unless ($expanded) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | $keep_from_lock->( sub { 1 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 292 | push @$warnings, 'bundle '.$_->{bundle}.'@'.$b->{source}.': '.$_->{message} for @{ $expanded->{warnings} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 292 | for my $m ( @{ $expanded->{items} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 12 | $offer->( $m->{type}, $m->{name}, { from => $label, source => $b->{source}, live => 1, via => $label, chains => $m->{chains} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 292 | my @missing; # identities already warned about for this bundle | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 292 | for my $fs ( @{ $x->{foreign} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 280 | my ( $f, $served ) = @{$fs}{qw( f served )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 280 | ▶ | my $cat = defined $served ? $catalog_of->($served) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if ( !defined $served && !grep { same_identity( $_, $f->{url} ) } @missing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $served or grep {same_identity($_, $f->{"url"});} @missing
MC/DC50%1/2
defined $served or grep {same_identity($_, $f->{"url"});} @missing
defined $served
grep {same_identity($_, $f->{"url"});} @missing
Truth table66%2/3
A or B
A= defined $servedB= grep {same_identity($_, $f->{"url"});} @missing
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 52 | push @missing, $f->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 52 | push @$warnings, 'bundle '.$b->{name}.'@'.$b->{source}.' needs '.$f->{spec}.' ('.$f->{url}.'): run skilletor install '.$label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 280 | ▶ | unless ($cat) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Missing, untrusted or unresolvable: installed copies stay (spec §15.6). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $keep_from_lock->( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my ( $l ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $ls = $l->{entry}{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | return $l->{type} eq $f->{type} && !_str_eq( $ls, $b->{source} ) && matches_pattern( $f->{name}, $l->{name} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | && ( !defined $served || _str_eq( $ls, $served ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$l->{'type'} eq $f->{'type'} && !_str_eq($ls, $b->{'source'}) && matches_pattern($f->{'name'}, $l->{'name'}) && (!defined($served) || _str_eq($ls, $served))
$l->{"type"} eq $f->{"type"} and not _str_eq($ls, $b->{"source"}) and matches_pattern($f->{"name"}, $l->{"name"})
$l->{"type"} eq $f->{"type"} and not _str_eq($ls, $b->{"source"})
not defined $served or _str_eq($ls, $served)
MC/DC0%0/5
$l->{'type'} eq $f->{'type'} && !_str_eq($ls, $b->{'source'}) && matches_pattern($f->{'name'}, $l->{'name'}) && (!defined($served) || _str_eq($ls, $served))
$l->{"type"} eq $f->{"type"}
not _str_eq($ls, $b->{"source"})
matches_pattern($f->{"name"}, $l->{"name"})
not defined $served
_str_eq($ls, $served)
Truth table0%0/6
A and not(B) and C && not(D) or E
A= $l->{"type"} eq $f->{"type"}B= not _str_eq($ls, $b->{"source"})C= matches_pattern($f->{"name"}, $l->{"name"})D= not defined $servedE= _str_eq($ls, $served)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 52 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 52 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 228 | my $hits = match_entry( $cat, $f->{type}, $f->{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 228 | ▶ | if ( defined( my $miss = entry_miss( $f->{type}, $f->{name}, scalar @$hits ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | push @$warnings, 'bundle '.$f->{chain}{path}[-1].'@'.$b->{source}.': '.( $miss =~ s/ in the source\z//r ).' in '.$served; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 228 | for my $ci (@$hits) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 228 | $offer->( $ci->{type}, $ci->{name}, { from => $label, source => $served, live => 1, via => $label, chains => [ $f->{chain} ] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Explicit entries win over every offer; they get no bundle vars (spec §15.3), but record the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # same-source bundles that also yield them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 5275 | my %explicit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 5275 | for my $item ( @{ $scope_cfg->{install} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 5455 | my $key = $target_key->( $item->{type}, $item->{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 5455 | $explicit{$key} = { source => $item->{source}, raw => $item->{raw} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | ▶ | my @via = map { $_->{via} } grep { defined $_->{via} && _str_eq( $_->{source}, $item->{source} ) && $_->{name} eq $item->{name} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
defined $_->{'via'} && _str_eq($_->{'source'}, $item->{'source'}) && $_->{'name'} eq $item->{'name'}
defined $_->{"via"} and _str_eq($_->{"source"}, $item->{"source"})
MC/DC33%1/3
defined $_->{'via'} && _str_eq($_->{'source'}, $item->{'source'}) && $_->{'name'} eq $item->{'name'}
defined $_->{"via"}
_str_eq($_->{"source"}, $item->{"source"})
$_->{'name'} eq $item->{'name'}
Truth table50%2/4
A and B && C
A= defined $_->{"via"}B= _str_eq($_->{"source"}, $item->{"source"})C= $_->{'name'} eq $item->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 5455 | ▶ | @{ $offers{$key} ? $offers{$key}{offers} : [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 5455 | $build_item->( $item, { via => \@via, declaredBy => [ $item->{raw} ] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # Bundle var conflicts (spec §15.3), reported once per key and pair of bundles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 5274 | my ( %conflicts, @conflict_order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 5274 | for my $key (@offer_order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 417 | my $o = $offers{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 417 | ▶ | if ( my $claim = $explicit{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 6 | for my $x ( @{ $o->{offers} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 8 | ▶ | next if _str_eq( $x->{source}, $claim->{source} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | push @$warnings, $o->{type}.' "'.$x->{name}.'" from '.$x->{from}.' ignored: explicitly declared as '.$claim->{raw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 411 | my @names = _uniq( map { $_->{name} } @{ $o->{offers} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 411 | ▶ | if ( _uniq( map { $_->{source} // '' } @{ $o->{offers} } ) > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_->{"source"} // ""
MC/DC0%0/1
$_->{"source"} // ""
$_->{"source"}
Truth table50%1/2
A
A= $_->{"source"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my @from = _uniq( map { $_->{from} } @{ $o->{offers} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | push @$warnings, $o->{type}.' '.join( ' and ', map { '"'.$_.'"' } @names ).' offered by '.join( ' and ', @from ).'; skipped'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $keep_if_locked->( $TYPE_DIR{ $o->{type} }.'/'.$_, $o->{type} ) for @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # One source: installed once, however many of its wildcards and bundles yield it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 411 | my $source = $o->{offers}[0]{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 411 | for my $name (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 411 | my @mine = grep { $_->{name} eq $name } @{ $o->{offers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 411 | my @live = grep { $_->{live} } @mine; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 411 | ▶ | unless (@live) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $keep_if_locked->( $TYPE_DIR{ $o->{type} }.'/'.$name, $o->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 411 | ▶ | unless ( _valid_item_name($name) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | push @$warnings, $o->{type}.' "'.$name.'" from '.$live[0]{from}.' skipped: invalid item name'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 411 | ▶ | my @via = map { defined $_->{via} ? $_->{via} : () } @mine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 411 | ▶ | my @chains = map { @{ $_->{chains} // [] } } @live; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{"chains"} // []
MC/DC100%1/1
$_->{"chains"} // []
$_->{"chains"}
Truth table100%2/2
A
A= $_->{"chains"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | my $bundle_vars = _merge_chain_vars( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | \@chains, $source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my ( $var, $setters ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $k = '"'.$var.'": '.join( ' and ', @$setters ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | push @conflict_order, $k unless $conflicts{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | push @{ $conflicts{$k} }, $o->{type}.' '.$name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 411 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $build_item->( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | { type => $o->{type}, name => $name, source => $source, target => $TYPE_DIR{ $o->{type} }.'/'.$name }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 411 | { bundleVars => $bundle_vars, via => \@via, declaredBy => [ _uniq( map { $_->{from} } @live ) ] }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 5274 | for my $k (@conflict_order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | push @$warnings, 'bundle vars conflict on '.$k.' set different values; neither applies to '.join( ', ', @{ $conflicts{$k} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 5274 | ▶ | if ($hooks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | my $run_info = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | resolved => \%resolved, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | resolved_order => \@resolved_order, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | catalogs => \%catalogs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | old_lock => $old_lock, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # Per bundle label, the other sources its entries are served by (spec §15.6). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 4883 | ▶ | served => { map { ( $_->{label} => [ map { defined $_->{served} ? $_->{served} : () } @{ $_->{foreign} } ] ) } @expansions }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 4883 | undef $_ for $resolve_all, $catalog_of, $lookup, $build_item, $offer, $set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 4883 | ▶ | return wantarray ? ( $rep, $run_info ) : $rep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # The sources the scope needed, and what became of them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 391 | for my $name (@resolved_order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 367 | my $r = $resolved{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 367 | my $src = $config->source_of( $scope, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 367 | ▶ | my $backend = $r ? $r->{backend} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 367 | ▶ | $backend = eval { Skilletor::Backend->resolve( $src, $self->home ) } if !$backend && $src; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $backend and $src
MC/DC50%1/2
not $backend and $src
not $backend
$src
Truth table66%2/3
not(A) and B
A= not $backendB= $src
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 367 | my $info = { name => $name, state => 'failed' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if ( !$src ) { $info->{state} = 'unknown' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 318 | ▶ | elsif ( $r && !( exists $catalogs{$name} && !defined $catalogs{$name} ) ) { $info->{state} = 'resolved' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$r and not exists $catalogs{$name} && !defined($catalogs{$name})
exists $catalogs{$name} && !defined($catalogs{$name})
MC/DC33%1/3
$r and not exists $catalogs{$name} && !defined($catalogs{$name})
$r
exists $catalogs{$name}
!defined($catalogs{$name})
Truth table50%2/4
A and not(B && not(C))
A= $rB= exists $catalogs{$name}C= !defined($catalogs{$name})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | elsif ( !$r && grep { $_->{name} eq $name } @{ $rep->{trustRequests} } ) { $info->{state} = 'untrusted' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not $r and grep {$_->{"name"} eq $name;} @{$$rep{"trustRequests"};}
MC/DC0%0/2
not $r and grep {$_->{"name"} eq $name;} @{$$rep{"trustRequests"};}
not $r
grep {$_->{"name"} eq $name;} @{$$rep{"trustRequests"};}
Truth table33%1/3
not(A) and B
A= not $rB= grep {$_->{"name"} eq $name;} @{$$rep{"trustRequests"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 367 | ▶ | if ($backend) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 367 | $info->{backend} = $backend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 367 | ▶ | $info->{cache} = cache_name( git_identity( $backend->{address}, $backend->{ref} ) ) if $backend->{kind} eq 'git'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 367 | ▶ | $info->{cache} = cache_name( $backend->{address} ) if $backend->{kind} eq 'url'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 367 | ▶ | if ($r) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 318 | $info->{dir} = $r->{dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 318 | $info->{version} = $r->{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 367 | push @{ $rep->{sources} }, $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # The closures above refer to each other through these; break the cycles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 391 | undef $_ for $resolve_all, $catalog_of, $lookup, $build_item, $offer, $set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 391 | return $rep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 400 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||