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 Dec 20, 2024
1 parent 0c0408c commit 42dd065
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 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 @@ -430,11 +430,11 @@ sub changes_between {
5.041004 => '2024-09-20',
5.041005 => '2024-10-20',
5.041006 => '2024-11-20',
5.041007 => '2024-12-20',
41.007 => '2024-12-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 @@ -22478,7 +22478,7 @@ for my $version ( sort { $a <=> $b } keys %released ) {
removed => {
}
},
5.041007 => {
41.007 => {
delta_from => 5.041006,
changed => {
'B::Op_private' => '5.041007',
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 @@ -2070,7 +2070,7 @@ my %delta = (
removed => {
}
},
5.041007 => {
41.007 => {
delta_from => 5.041006,
changed => {
},
Expand Down

0 comments on commit 42dd065

Please sign in to comment.