Skip to content

Commit

Permalink
fix package search for packages that differ only in case
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Apr 29, 2015
1 parent 6c4aacc commit 9e49fd2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Revision history for CPAN-Common-Index

{{$NEXT}}

[FIXED]

- Fixed package name search when there are packages that
differ only in case (e.g. "If" vs "if")

0.005 2014-09-23 21:26:13-04:00 America/New_York

[FIXED]
Expand Down
9 changes: 5 additions & 4 deletions lib/CPAN/Common/Index/Mirror.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ sub search_packages {
# binary search 02packages on package
my $pos = look $fh, $args->{package}, { xfrm => \&_xform_package, fold => 1 };
return if $pos == -1;
# XXX eventually, loop lines until package doesn't match so we can
# search an index with unique package+version, not just package
my $line = <$fh>;
push @found, _match_package_line( $line, $rules );
# loop over any case-insensitive matching lines
LINE: while ( my $line = <$fh> ) {
last unless $line =~ /\A\Q$args->{package}\E\s+/i;
push @found, _match_package_line( $line, $rules );
}
}
else {
# iterate all lines looking for match
Expand Down
Binary file modified t/CUSTOM/mypackages.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion t/CUSTOM/uncompressed
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Acme::Samurai 0.02 L/LO/LOCAL/Acme-Samurai-0.02.tar.gz
attributes 0.2 F/FL/FLORA/perl-5.17.4.tar.bz2
Dist::Zilla 4.300034 R/RJ/RJBS/Dist-Zilla-4.300034.tar.gz
File::Marker 0.13 D/DA/DAGOLDEN/File-Marker-0.13.tar.gz
If undef F/FG/FGLOCK/v6-0.044.tar.gz
if 0.0601 I/IL/ILYAZ/modules/if-0.0601.tar.gz
Moo::Role undef M/MS/MSTROUT/Moo-1.001000.tar.gz
Parse::CPAN::Meta 1.4404 D/DA/DAGOLDEN/Parse-CPAN-Meta-1.4404.tar.gz
ZZZ::Custom 1.2 L/LO/LOCAL/ZZZ-Custom-1.2.tar.gz

9 changes: 9 additions & 0 deletions t/lib/CommonTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ sub test_find_package {
uri => 'cpan:///distfile/FLORA/perl-5.17.4.tar.bz2',
},
},
{
label => 'query on package duplicated in another case',
query => { package => 'if', },
result => {
package => 'if',
version => '0.0601',
uri => 'cpan:///distfile/ILYAZ/modules/if-0.0601.tar.gz'
},
},
);

for my $c (@cases) {
Expand Down

0 comments on commit 9e49fd2

Please sign in to comment.