| 1 | package CPAN::InGit::ArchiveTree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | our $VERSION = '0.006'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: An object managing a CPAN file structure in a Git Tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Scalar::Util 'refaddr', 'blessed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use POSIX 'strftime'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use IO::Uncompress::Gunzip qw( gunzip $GunzipError ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use JSON::PP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Log::Any '$log'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | extends 'CPAN::InGit::MutableTree'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 79 | ▶ | sub BUILD($self, $args, @) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 79 | ▶ | $self->load_config if $self->config_blob; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 79 | ▶ | $self->name($self->branch? $self->branch->shorthand : '(anonymous)') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | unless defined $self->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 11 | has name => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | has config => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 158 | ▶ | sub config_blob($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_blob: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 158 | ▶ | my $ent= $self->get_path('cpan_ingit.json') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 128 | ▶ | return $ent->[0]->is_blob? $ent->[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 64 | ▶ | sub load_config($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 64 | ▶ | my $cfg_blob= $self->config_blob | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | or die "Missing '/cpan_ingit.json'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 64 | my $attrs= JSON::PP->new->utf8->relaxed->decode($cfg_blob->content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 64 | ▶ | ref $attrs eq 'HASH' or croak "Configuration file does not contain an object?".$cfg_blob->content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 64 | $self->{config}= $attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 64 | $self->_unpack_config($self->{config}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 64 | $attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 64 | ▶ | sub _unpack_config($self, $config) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unpack_config: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 64 | for (qw( default_import_sources corelist_perl_version canonical_url )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 192 | ▶ | $self->$_($config->{$_}) if defined $config->{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 15 | ▶ | sub _pack_config($self, $config) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pack_config: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | for (qw( default_import_sources corelist_perl_version canonical_url )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 45 | my $val= $self->$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 45 | ▶ | $val= "$val" if ref $val eq 'version'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 45 | $config->{$_}= $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 15 | ▶ | sub write_config($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_config: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | my $config= $self->config // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->config // {}
MC/DC0%0/1
$self->config // {}
$self->config
Truth table50%1/2
A
A= $self->config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 15 | $self->_pack_config($config); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 15 | my $json= JSON::PP->new->utf8->canonical->pretty->encode($config); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 15 | ▶ | $self->set_path('cpan_ingit.json', \$json) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->config_blob and $self->config_blob->content eq $json
MC/DC0%0/2
$self->config_blob and $self->config_blob->content eq $json
$self->config_blob
$self->config_blob->content eq $json
Truth table33%1/3
A and B
A= $self->config_blobB= $self->config_blob->content eq $json
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | unless $self->config_blob && $self->config_blob->content eq $json; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 15 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 11 | has canonical_url => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | has default_import_sources => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 11 | has corelist_perl_version => ( is => 'rw', default => '5.008009' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 148 | ▶ | sub package_details_blob($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package_details_blob: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 148 | ▶ | my $ent= $self->get_path('modules/02packages.details.txt') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 131 | ▶ | return $ent->[0]->is_blob? $ent->[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 11 | has package_details => ( is => 'rw', lazy => 1, builder => 1, clearer => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 12 | ▶ | sub _build_package_details($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_package_details: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | $self->parse_package_details($self->package_details_blob->content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | ▶ | sub parse_package_details($self, $content) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_package_details: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 12 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | ▶ | while ($content =~ /\G([^:\n]+):\s+(.*)\n/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 96 | $attrs{$1}= $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 12 | ▶ | $content =~ /\G\n/gc or croak "missing blank line after headers"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 12 | my %by_mod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | my %by_dist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 12 | ▶ | while ($content =~ /\G(\S+)\s+(\S+)\s+(\S+)\n/gc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 21 | ▶ | my $row= [ $1, ($2 eq 'undef'? undef : $2), $3 ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 21 | $by_mod{$1}= $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 21 | push @{$by_dist{$3}}, $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 12 | ▶ | pos $content == length $content | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | or croak "Parse error at '".substr($content, pos($content), 10)."'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 12 | ▶ | my $timestamp = $attrs{'Last-Updated'}? Time::Piece->strptime($attrs{'Last-Updated'}, "%a, %d %b %Y %H:%M:%S GMT") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | : undef; # TODO: fall back to date from branch commit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 12 | last_update => $timestamp, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | by_module => \%by_mod, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | by_dist => \%by_dist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 23 | ▶ | sub write_package_details($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_package_details: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 23 | ▶ | my $url= $self->canonical_url // 'cpan_mirror_ingit.local'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->canonical_url // "cpan_mirror_ingit.local"
MC/DC0%0/1
$self->canonical_url // "cpan_mirror_ingit.local"
$self->canonical_url
Truth table50%1/2
A
A= $self->canonical_url
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # on initial creation, need to write an empty package_details without triggering | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # lazy-build of package_details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | my @mod_list= !$self->package_details_blob? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 23 | ▶ | : values %{$self->package_details->{by_module}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 23 | my $line_count= @mod_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 23 | my $date= strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 23 | my $content= <<~END; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | File: 02packages.details.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | URL: $url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | Description: Package names found in directory \$CPAN/authors/id/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Columns: package name, version, path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | Intended-For: Automated fetch routines, namespace documentation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | Written-By: PAUSE version 1.005 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | Line-Count: $line_count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | Last-Updated: $date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # List can be huge, so try to be efficient about stringifying it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 23 | @mod_list= sort { fc $a->[0] cmp fc $b->[0] } @mod_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 23 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 23 | for (@mod_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 9 | ▶ | push @lines, sprintf("%s %s %s\n", $_->[0], $_->[1] // 'undef', $_->[2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->[1] // "undef"
MC/DC100%1/1
$_->[1] // "undef"
$_->[1]
Truth table100%2/2
A
A= $_->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 23 | $self->set_path('modules/02packages.details.txt', \join('', $content, @lines)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 7 | ▶ | sub has_module($self, $mod_name, $reqs=undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_module: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | my $mod_ver= $self->get_module_version($mod_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | ▶ | if (defined $mod_ver && defined $reqs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $mod_ver and defined $reqs
MC/DC100%2/2
defined $mod_ver and defined $reqs
defined $mod_ver
defined $reqs
Truth table100%3/3
A and B
A= defined $mod_verB= defined $reqs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | ▶ | $reqs= CPAN::Meta::Requirements->from_string_hash({ $mod_name => $reqs }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | unless ref $reqs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | return !!$reqs->accepts_module($mod_name, $mod_ver); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | return defined $mod_ver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 20 | ▶ | sub get_module_version($self, $mod_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_module_version: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 20 | ▶ | if (my $current= $self->package_details->{by_module}{$mod_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | my $mod_ver= $current->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # grab the version out of the package filename? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 13 | ▶ | if (!defined $mod_ver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | $mod_ver= $current->[2] =~ /-([0-9]+(?:\.[0-9_]+?)*)\./? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | : 0; # return 0 to differentiate from undef=nonexisting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 13 | return $mod_ver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } elsif ($mod_name eq 'perl') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return $self->corelist_perl_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | ▶ | sub get_module_dist($self, $mod_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_module_dist: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | my $by_name= $self->package_details->{by_module}{$mod_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | return $by_name? $by_name->[2] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 10 | ▶ | sub meta_path_for_dist($self, $author_path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta_path_for_dist: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # replace archive extension with '.meta.json' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 10 | $author_path =~ s/\.(zip|tar\.gz|tgz|tar\.bz2|tbz2)\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | return "authors/id/$author_path.meta"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | ▶ | sub import_dist($self, $peer, $author_path, %options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_dist: called CC=7 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | my $dist_path= "authors/id/$author_path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | ▶ | my $distfile_ent= $peer->get_path($dist_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | or croak "Import source branch '".$peer->name."' does not contain $dist_path"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | $log->info("Importing $author_path from ".$peer->name." to ".$self->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | my $existing_ent= $self->get_path($dist_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # If exists, must be same gitobj as before or this is an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | ▶ | if ($existing_ent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | croak "$dist_path already exists with different content" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | unless $existing_ent->[0]->id eq $distfile_ent->[0]->id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | $self->set_path($dist_path, $distfile_ent->[0], mode => $distfile_ent->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | my $modules_registered= $peer->package_details->{by_dist}{$author_path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | if ($modules_registered) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | $self->package_details->{by_dist}{$author_path}= [ @$modules_registered ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | $self->package_details->{by_module}{$_->[0]}= $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | for @$modules_registered; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | $self->write_package_details; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | my $meta_path= $self->meta_path_for_dist($author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | my $meta_ent= $peer->get_path($meta_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | ▶ | if ($meta_ent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | $self->set_path($meta_path, $meta_ent->[0], mode => $meta_ent->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # TODO: parse module for META.json and dependnecies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | $log->warn("No META for $author_path"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | ▶ | sub get_dist_meta($self, $author_path, %options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dist_meta: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 5 | my $meta_path= $self->meta_path_for_dist($author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | my $meta_ent= $self->get_path($meta_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | return CPAN::Meta->load_string($meta_ent->[0]->content) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | if $meta_ent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # TODO: process the tar file to generate the meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | ▶ | sub _filter_prereqs($self, $reqs, $corelist={}, $log_prefix='') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_prereqs: called CC=10 SCAR=33.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | for my $mod (sort $reqs->required_modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | my $req_version= $reqs->requirements_for_module($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | my $have_ver= $self->get_module_version($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # Is this requirement already in the tree? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | ▶ | if (defined $have_ver && $reqs->accepts_module($mod, $have_ver)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $have_ver and $reqs->accepts_module($mod, $have_ver)
MC/DC0%0/2
defined $have_ver and $reqs->accepts_module($mod, $have_ver)
defined $have_ver
$reqs->accepts_module($mod, $have_ver)
Truth table33%1/3
A and B
A= defined $have_verB= $reqs->accepts_module($mod, $have_ver)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $log->debugf($log_prefix.'(requirement %s %s already satisfied by %s from %s)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $mod, $req_version, $have_ver, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ($mod eq 'perl'? 'corelist_perl_version' : $self->get_module_dist($mod))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | if $log->is_info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $reqs->clear_requirement($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Is the requirement satisfied by a core perl module in the version of perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # the app will be running under? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ▶ | elsif (defined $corelist->{$mod} && $reqs->accepts_module($mod, $corelist->{$mod})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $corelist->{$mod} and $reqs->accepts_module($mod, $corelist->{$mod})
MC/DC0%0/2
defined $corelist->{$mod} and $reqs->accepts_module($mod, $corelist->{$mod})
defined $corelist->{$mod}
$reqs->accepts_module($mod, $corelist->{$mod})
Truth table33%1/3
A and B
A= defined $corelist->{$mod}B= $reqs->accepts_module($mod, $corelist->{$mod})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $log->debugf($log_prefix.'(requirement %s %s satisfied by corelist)', $mod, $req_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $reqs->clear_requirement($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 6 | return $reqs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # merges new requirements into existing, and returns a list of anything that changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | sub _merge_prereqs($self, $reqs, $new_reqs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_merge_prereqs: called CC=6 SCAR=18.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | my $before= $reqs->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | $reqs->add_requirements($new_reqs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | my $after= $reqs->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | my @changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | for my $mod (sort $new_reqs->required_modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | if (($before->{$mod} // '') ne ($after->{$mod} // 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$before->{$mod} // ""
$after->{$mod} // 0
MC/DC0%0/1
$before->{$mod} // ""
$before->{$mod}
MC/DC0%0/1
$after->{$mod} // 0
$after->{$mod}
Truth table50%1/2
A
A= $before->{$mod}
Truth table50%1/2
A
A= $after->{$mod}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | push @changed, $mod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | ▶ | $log->infof(' requires %s%s', $mod, $after->{$mod}? " $after->{$mod}" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | return @changed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | ▶ | sub import_modules($self, $reqs, %options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_modules: called CC=31 SCAR=40.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | my %imported_dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # Build list of source trees | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 4 | ▶ | my $sources= $options{sources} // $self->default_import_sources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options{"sources"} // $self->default_import_sources
MC/DC0%0/2
$options{"sources"} // $self->default_import_sources
$options{"sources"}
$self->default_import_sources
Truth table33%1/3
A // B
A= $options{"sources"}B= $self->default_import_sources
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ▶ | $sources && @$sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sources and @$sources
MC/DC0%0/2
$sources and @$sources
$sources
@$sources
Truth table33%1/3
A and B
A= $sourcesB= @$sources
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | or croak "No import sources specified"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # coerce every source name to an ArchiveTree object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 4 | my @autocommit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 4 | for (@$sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | ▶ | unless (ref $_ and $_->can('package_details')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_ and $_->can("package_details")
MC/DC0%0/2
ref $_ and $_->can("package_details")
ref $_
$_->can("package_details")
Truth table33%1/3
A and B
A= ref $_B= $_->can("package_details")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | my $t= $self->parent->get_archive_tree($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | or croak "No such archive tree $_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # If we've created new objects for MirrorTree and the MirrorTree has autofetch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # enabled, then we also need to commit those changes before returning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 4 | ▶ | push @autocommit, $t if $t->can('autofetch') && $t->autofetch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t->can("autofetch") and $t->autofetch
MC/DC0%0/2
$t->can("autofetch") and $t->autofetch
$t->can("autofetch")
$t->autofetch
Truth table33%1/3
A and B
A= $t->can("autofetch")B= $t->autofetch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | $_= $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # Coerce the argument to a Requirements object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | require CPAN::Meta::Requirements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | my $prereq_phases= [qw( configure build runtime test )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | my $prereq_types= [qw( requires )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | my $log_recommends= !grep $_ eq 'recommends', @$prereq_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | my $recommended= CPAN::Meta::Requirements->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # coerce the requirements into a CPAN::Meta::Requirements object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | $reqs= ref $reqs eq 'HASH'? CPAN::Meta::Requirements->from_string_hash($reqs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition16%1/6
builtin::blessed($reqs) and $reqs->isa("CPAN::Meta::Requirements")
builtin::blessed($reqs) and $reqs->isa("CPAN::Meta::Prereqs")
MC/DC0%0/2
builtin::blessed($reqs) and $reqs->isa("CPAN::Meta::Requirements")
builtin::blessed($reqs)
$reqs->isa("CPAN::Meta::Requirements")
MC/DC0%0/2
builtin::blessed($reqs) and $reqs->isa("CPAN::Meta::Prereqs")
builtin::blessed($reqs)
$reqs->isa("CPAN::Meta::Prereqs")
Truth table33%1/3
A and B
A= builtin::blessed($reqs)B= $reqs->isa("CPAN::Meta::Requirements")
Truth table0%0/3
A and B
A= builtin::blessed($reqs)B= $reqs->isa("CPAN::Meta::Prereqs")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | : blessed($reqs) && $reqs->isa('CPAN::Meta::Requirements')? $reqs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | : blessed($reqs) && $reqs->isa('CPAN::Meta::Prereqs')? $reqs->merged_requirements($prereq_phases, $prereq_types) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | : croak "Expected CPAN::Meta::Requirements object, ::Prereqs object, or HASH ref"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # Determine what module versions were available for the app's version of perl. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | require Module::CoreList; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | my $perl_v= $options{corelist_perl_version} // $self->corelist_perl_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options{"corelist_perl_version"} // $self->corelist_perl_version
MC/DC0%0/2
$options{"corelist_perl_version"} // $self->corelist_perl_version
$options{"corelist_perl_version"}
$self->corelist_perl_version
Truth table33%1/3
A // B
A= $options{"corelist_perl_version"}B= $self->corelist_perl_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | $perl_v= version->parse($perl_v)->numify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | ▶ | my $corelist= Module::CoreList::find_version($perl_v) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | or carp "No corelist for $perl_v"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Filter out the prereqs we already have, or which are in the corelist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | $log->tracef('todo reqs: %s', $reqs->as_string_hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | $self->_filter_prereqs($reqs, $corelist); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 4 | my @initial_list= $reqs->required_modules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | my @todo= @initial_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 4 | ▶ | while (@todo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | my $mod= shift @todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | my $req_version= $reqs->requirements_for_module($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | $log->infof('Add %s %s', $mod, $req_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Walk through the list of import sources looking for a version that works | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 5 | my ($author_path, $prereqs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | for my $peer (@$sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 5 | my $peer_ver= $peer->get_module_version($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 5 | ▶ | if (!defined $peer_ver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $log->debugf(' branch %s does not have module %s', $peer->name, $mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif (!$reqs->accepts_module($mod, $peer_ver)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $log->debugf(' branch %s module %s version %s does not match %s', $peer->name, $mod, $peer_ver, $req_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 5 | $log->debugf(' branch %s has %s %s, matching %s', $peer->name, $mod, $peer_ver, $req_version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | $author_path= $peer->get_module_dist($mod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | $self->import_dist($peer, $author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | my $meta= $self->get_dist_meta($author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 5 | ▶ | $prereqs= $meta->effective_prereqs if $meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 5 | $imported_dists{$author_path}= $peer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 5 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5 | ▶ | croak("No import_sources branch had module $mod with version $req_version") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | unless length $author_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # Push things into the TODO list if they aren't already in %$reqs or if they have a higher | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # version requirement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | ▶ | if ($prereqs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | my $dist_reqs= $prereqs->merged_requirements($prereq_phases, $prereq_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | $log->infof('Dist %s:', $author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | my $n= $#todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | push @todo, $self->_merge_prereqs($reqs, $self->_filter_prereqs($dist_reqs, $corelist, ' ')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | ▶ | $log->infof(' (no additional reqs)') if $#todo == $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # Collect recommendations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ▶ | if ($log_recommends) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | my $dist_recommends= $prereqs->merged_requirements(['runtime'], ['recommends']); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | $self->_filter_prereqs($dist_recommends, $corelist); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | my @list= sort $dist_recommends->required_modules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | ▶ | $log->noticef('Dist %s recommends %s', $mod, [ sort @list ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | if @list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | $recommended->add_requirements($dist_recommends); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 4 | ▶ | if ($log_recommends) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 4 | ▶ | if (my @list= sort $recommended->required_modules) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $log->notice('Full list of recommended modules:'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | $log->noticef(' %s %s', $_, $recommended->requirements_for_module($_)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | for @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | # If any sources are 'autofetch' and caller didn't supply the MirrorTree object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # commit the changes before returning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | for my $mirror (grep $_->has_changes, @autocommit) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $message= join "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 'Auto-commit packages fetched for branch '.$self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 'For $archive_tree->import_modules:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | map(" - $_ ".$reqs->requirements_for_module($_), @initial_list), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $mirror->commit($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | return \%imported_dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub import_cpanfile_snapshot($self, $snapshot_spec, %options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_cpanfile_snapshot: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my %imported_dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | my $sources= $options{sources} // $self->default_import_sources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$options{"sources"} // $self->default_import_sources
MC/DC0%0/2
$options{"sources"} // $self->default_import_sources
$options{"sources"}
$self->default_import_sources
Truth table0%0/3
A // B
A= $options{"sources"}B= $self->default_import_sources
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $sources && @$sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sources and @$sources
MC/DC0%0/2
$sources and @$sources
$sources
@$sources
Truth table0%0/3
A and B
A= $sourcesB= @$sources
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | or croak "No import sources specified"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # coerce every source name to an ArchiveTree object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my @autocommit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | for (@$sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | unless (ref $_ and $_->can('package_details')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_ and $_->can("package_details")
MC/DC0%0/2
ref $_ and $_->can("package_details")
ref $_
$_->can("package_details")
Truth table0%0/3
A and B
A= ref $_B= $_->can("package_details")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my $t= $self->parent->get_archive_tree($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | or croak "No such archive tree $_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # If we've created new objects for MirrorTree and the MirrorTree has autofetch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # enabled, then we also need to commit those changes before returning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | push @autocommit, $t if $t->can('autofetch') && $t->autofetch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$t->can("autofetch") and $t->autofetch
MC/DC0%0/2
$t->can("autofetch") and $t->autofetch
$t->can("autofetch")
$t->autofetch
Truth table0%0/3
A and B
A= $t->can("autofetch")B= $t->autofetch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $_= $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | dist: for my $dist_name (sort keys %$snapshot_spec) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $dist_info= $snapshot_spec->{$dist_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # Locate 'pathname' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $author_path= $dist_info->{pathname}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | unless ($author_path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $msg= "Dist $dist_name lacks 'pathname' attribute"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $options{partial}? $log->notice($msg) : croak $msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Which source has this file? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | for my $source (@$sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $log->debugf("check %s for %s", $source->name, $author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | my $distfile_ent= $source->get_path("authors/id/$author_path") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $self->import_dist($source, $author_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $imported_dists{$author_path}= $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # Update index with the modules provided by this distribution if it wasn't imported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # from $source by import_dist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (!$source->package_details->{by_dist}{$author_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # Fall back to the 'provides' from the cpanfile.snapshot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if (ref $dist_info->{provides} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | my @mod_index= map [ $_, $dist_info->{provides}{$_}, $author_path ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | keys %{$dist_info->{provides}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->package_details->{by_dist}{$author_path}= \@mod_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | $self->package_details->{by_module}{$_->[0]}= $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | for @mod_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->write_package_details; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $msg= "Snapshot lacks 'provides' for $dist_name, and not indexed in ".$source->name." either"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | $options{partial}? $log->notice($msg) : croak $msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | next dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $msg= "No source contains file $author_path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $options{partial}? $log->notice($msg) : croak $msg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # If any sources are 'autofetch' and caller didn't supply the MirrorTree object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # commit the changes before returning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | for my $mirror (grep $_->has_changes, @autocommit) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $message= join "\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 'Auto-commit packages fetched for branch '.$self->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 'For $archive_tree->import_cpanfile_snapshot', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $mirror->commit($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return \%imported_dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||