Skip to content

Commit

Permalink
fix latest changes when dist version is unparsable
Browse files Browse the repository at this point in the history
If the dist version is not parsable as a version, just do string
comparisons against the versions found in the change log.
  • Loading branch information
haarg committed Oct 1, 2016
1 parent ddfa006 commit 6292a93
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/MetaCPAN/Web/Model/API/Changes.pm
Expand Up @@ -30,12 +30,16 @@ sub last_version {
}
return [] unless $releases && @$releases;

my $version = $release->{version};
eval { $version = version->parse($version) };

my @releases = sort { $b->[0] <=> $a->[0] }
map {
my $v = $_->{version} =~ s/-TRIAL$//r;
my $dev = $_->{version} =~ /_|-TRIAL$/
|| $_->{note} && $_->{note} =~ /\bTRIAL\b/;
[ version->parse($v), $v, $dev, $_ ];
my $ver = (ref $version && length $v && eval { version->parse($v) }) || $v;
[ $ver, $v, $dev, $_ ];
} @$releases;

my @changelogs;
Expand All @@ -49,7 +53,7 @@ sub last_version {
last;
}
}
elsif ( $r->[0] eq $release->{version} ) {
elsif ( $r->[0] eq $version ) {
push @changelogs, $r->[3];
$found = 1;
}
Expand Down

0 comments on commit 6292a93

Please sign in to comment.