Skip to content

Commit

Permalink
fix Module-CoreList to support versions larger than 5
Browse files Browse the repository at this point in the history
Important fixes include:
* sorting numerical versions using <=>
* properly computing the family for versions larger than 5
  • Loading branch information
book committed Jan 9, 2025
1 parent 75941c3 commit cfb495a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions dist/Module-CoreList/lib/Module/CoreList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sub _looks_like_invocant ($) { local $@; !!eval { $_[0]->isa(__PACKAGE__) } }
sub _undelta {
my ($delta) = @_;
my (%expanded, $delta_from, $base, $changed, $removed);
for my $v (sort keys %$delta) {
for my $v (sort { $a <=> $b } keys %$delta) {
($delta_from, $changed, $removed) = @{$delta->{$v}}{qw( delta_from changed removed )};
$base = $delta_from ? $expanded{$delta_from} : {};
my %full = ( %$base, %{$changed || {}} );
Expand Down Expand Up @@ -54,7 +54,7 @@ sub first_release_raw {

my @perls = $version
? grep { defined $version{$_}{ $module } &&
$version{$_}{ $module } ge $version } keys %version
$version{$_}{ $module } >= $version } keys %version
: grep { exists $version{$_}{ $module } } keys %version;

return @perls;
Expand All @@ -69,7 +69,7 @@ sub first_release_by_date {
sub first_release {
my @perls = &first_release_raw;
return unless @perls;
return (sort { $a cmp $b } @perls)[0];
return (sort { $a <=> $b } @perls)[0];
}

sub find_modules {
Expand Down Expand Up @@ -123,9 +123,9 @@ sub removed_from_by_date {
sub removed_raw {
shift if defined $_[1] and $_[1] =~ PKG_PATTERN and _looks_like_invocant $_[0];
my $mod = shift;
return unless my @perls = sort { $a cmp $b } first_release_raw($mod);
return unless my @perls = sort { $a <=> $b } first_release_raw($mod);
my $last = pop @perls;
my @removed = grep { $_ > $last } sort { $a cmp $b } keys %version;
my @removed = grep { $_ > $last } sort { $a <=> $b } keys %version;
return @removed;
}

Expand Down Expand Up @@ -431,11 +431,11 @@ sub changes_between {
5.041005 => '2024-10-20',
5.041006 => '2024-11-20',
5.041007 => '2024-12-20',
5.041008 => '2025-01-20',
41.008 => '2025-01-20',
);

for my $version ( sort { $a <=> $b } keys %released ) {
my $family = int ($version * 1000) / 1000;
my $family = $version > 41 ? int($version) : int( $version * 1000 ) / 1000;
push @{ $families{ $family }} , $version;
}

Expand Down Expand Up @@ -22499,11 +22499,11 @@ for my $version ( sort { $a <=> $b } keys %released ) {
removed => {
}
},
5.041008 => {
41.008 => {
delta_from => 5.041007,
changed => {
'B::Op_private' => '5.041008',
'Config' => '5.041008',
'B::Op_private' => '41.008000',
'Config' => '41.008000',
'Module::CoreList' => '5.20250120',
'Module::CoreList::Utils'=> '5.20250120',
},
Expand Down
10 changes: 5 additions & 5 deletions dist/Module-CoreList/lib/Module/CoreList/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sub first_release_raw {

my @perls = $version
? grep { exists $utilities{$_}{ $util } &&
$utilities{$_}{ $util } ge $version } keys %utilities
$utilities{$_}{ $util } >= $version } keys %utilities
: grep { exists $utilities{$_}{ $util } } keys %utilities;

return grep { exists $Module::CoreList::released{$_} } @perls;
Expand All @@ -47,7 +47,7 @@ sub first_release_by_date {
sub first_release {
my @perls = &first_release_raw;
return unless @perls;
return (sort { $a cmp $b } @perls)[0];
return (sort { $a <=> $b } @perls)[0];
}

sub removed_from {
Expand All @@ -63,10 +63,10 @@ sub removed_from_by_date {
sub removed_raw {
my $util = shift;
$util = shift if eval { $util->isa(__PACKAGE__) };
return unless my @perls = sort { $a cmp $b } first_release_raw($util);
return unless my @perls = sort { $a <=> $b } first_release_raw($util);
@perls = grep { exists $Module::CoreList::released{$_} } @perls;
my $last = pop @perls;
my @removed = grep { $_ > $last } sort { $a cmp $b } keys %utilities;
my @removed = grep { $_ > $last } sort { $a <=> $b } keys %utilities;
return @removed;
}

Expand Down Expand Up @@ -2077,7 +2077,7 @@ my %delta = (
removed => {
}
},
5.041008 => {
41.008 => {
delta_from => 5.041007,
changed => {
},
Expand Down
2 changes: 1 addition & 1 deletion lib/B/Op_private.pm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfb495a

Please sign in to comment.