From db658544cf44cff2cc97d05f20ad4d91d9a9e659 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Fri, 22 Aug 2014 11:50:20 -0500 Subject: [PATCH] update-dockapps.pl: Correctly sort alpha, beta, and release candidate versions. --- update-dockapps.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/update-dockapps.pl b/update-dockapps.pl index 53dde71..65caa1b 100755 --- a/update-dockapps.pl +++ b/update-dockapps.pl @@ -46,6 +46,7 @@ use warnings; use strict; use Git::Repository; use POSIX; +use Debian::Dpkg::Version; open DB, "dockapps.db.in" or die $!; my $db = do { local $/; }; @@ -73,7 +74,7 @@ foreach my $tag (@tags) { } foreach my $dockapp (keys %dockapps) { - my $latest_version = (sort keys $dockapps{$dockapp})[-1]; + my $latest_version = (sort by_version keys $dockapps{$dockapp})[-1]; if ($r->run("diff", "$dockapp-$latest_version", "HEAD", $dockapp)) { my $commit = $r->run("log", "-1", "--pretty=format:%H", $dockapp); @@ -95,7 +96,7 @@ foreach my $dockapp (keys %dockapps) { foreach my $dockapp (keys %dockapps) { my $versions = ""; - foreach my $version (reverse sort keys $dockapps{$dockapp}) { + foreach my $version (reverse sort by_version keys $dockapps{$dockapp}) { $versions .= "version-$version = " . $dockapps{$dockapp}{$version} . "\n"; } @@ -107,6 +108,9 @@ open DB, ">dockapps.db" or die $!; print DB $db; close DB; - - - +sub by_version { + (my $left = $a) =~ s/(a|b|rc)/~$1/; + (my $right = $b) =~ s/(a|b|rc)/~$1/; + Debian::Dpkg::Version->new($left) <=> + Debian::Dpkg::Version->new($right); +}