Porting/corelist-perldelta.pl: fix bug with 5.*.10 releases
authorAaron Crane <arc@cpan.org>
Thu, 20 Mar 2014 17:13:56 +0000 (17:13 +0000)
committerAaron Crane <arc@cpan.org>
Thu, 20 Mar 2014 17:21:03 +0000 (17:21 +0000)
The two aliases of the new Perl version (in this case, "5.01901" and
"5.019010") were being selected as the two versions to compare.
Unsurprisingly, those two versions have the same modules, so the
generated summary of changes was empty.

Porting/corelist-perldelta.pl

index 2b00f15..da02e7a 100755 (executable)
@@ -59,9 +59,7 @@ sub run {
   );
 
   # by default, compare latest two version in CoreList;
-  my @versions = sort keys %Module::CoreList::version;
-  my $old = $versions[-2];
-  my $new = $versions[-1];
+  my ($old, $new) = latest_two_perl_versions();
 
   # use the provided versions if present
   # @ARGV >=2 means [old_version] [new_version] [path/to/file]
@@ -89,6 +87,23 @@ sub run {
   exit 0;
 }
 
+sub latest_two_perl_versions {
+
+  my @versions = sort keys %Module::CoreList::version;
+
+  my $new = pop @versions;
+
+  # If a fully-padded version number ends in a zero (as in "5.019010"), that
+  # version shows up in %Module::CoreList::version both with and without its
+  # trailing zeros. So skip all versions that are numerically equal to $new.
+  pop @versions while @versions && $versions[-1] == $new;
+
+  die "Too few distinct core versions in %Module::CoreList::version ?!\n"
+    if !@versions;
+
+  return $versions[-1], $new;
+}
+
 # Given two perl versions, it returns a list describing the core distributions that have changed.
 # The first three elements are hashrefs corresponding to new, updated, and removed modules
 # and are of the form (mostly, see the special remarks about removed):