Skip to content

Commit 3d68cb3

Browse files
committed
match files to provides data based on exact match, not suffix
The files listed in provides data should be an exact match for the file path we are using. The regex matching was added in f3543c1 saying only "fixed regression". I can barely guess at what it was supposedly fixing, but it was definitely not the correct fix.
1 parent 4cb01be commit 3d68cb3

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

lib/MetaCPAN/Model/Release.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,16 @@ sub _modules_from_meta {
481481

482482
my $provides = $self->metadata->provides;
483483
my $files = $self->files;
484+
my %files = map +( $_->path => $_ ), @$files;
484485
foreach my $module ( sort keys %$provides ) {
485486
my $data = $provides->{$module};
486487
my $path = File::Spec->canonpath( $data->{file} );
487488

488-
# Obey no_index and take the shortest path if multiple files match.
489-
my ($file) = sort { length( $a->path ) <=> length( $b->path ) }
490-
grep { $_->indexed && $_->path =~ /\Q$path\E$/ } @$files;
489+
my $file = $files{$path}
490+
or next;
491+
492+
next unless $file->indexed;
491493

492-
next unless $file;
493494
$file->add_module( {
494495
name => $module,
495496
version => $data->{version},

t/lib/MetaCPAN/Tests/Release.pm

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,14 @@ test 'modules in Packages-1.103' => sub {
230230
= map { ( $_->{path} => $_->{module} ) } @{ $self->module_files };
231231

232232
foreach my $path ( sort keys %{ $self->modules } ) {
233-
my $desc = "File '$path' has expected modules";
234-
if ( my $got = delete $module_files{$path} ) {
235-
my $got = [ map +{%$_}, @$got ];
236-
$_->{associated_pod} //= undef for @$got;
233+
my $desc = "File '$path' has expected modules";
234+
my $got_modules = delete $module_files{$path} || [];
235+
my $got = [ map +{%$_}, @$got_modules ];
236+
$_->{associated_pod} //= undef for @$got;
237237

238238
# We may need to sort modules by name, I'm not sure if order is reliable.
239-
is_deeply $got, $self->modules->{$path}, $desc
240-
or diag Test::More::explain($got);
241-
}
242-
else {
243-
ok( 0, $desc );
244-
}
239+
is_deeply $got, $self->modules->{$path}, $desc
240+
or diag Test::More::explain($got);
245241
}
246242

247243
is( scalar keys %module_files, 0, 'all module files tested' )

t/release/file-duplicates.t

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ test_release(
2828
indexed => true,
2929
associated_pod => undef,
3030
} ],
31-
'lib/Dupe.pm' => [ {
32-
name => 'Dupe',
33-
version => '0.993',
34-
version_numified => '0.993',
35-
authorized => true,
36-
indexed => false,
37-
associated_pod => undef,
38-
} ],
31+
'lib/Dupe.pm' => [],
3932
'DupeX/Dupe.pm' => [
4033
{
4134
name => 'DupeX::Dupe',

0 commit comments

Comments
 (0)