[devscripts] 06/07: uscan: match substring for dir walking

Osamu Aoki osamu at moszumanska.debian.org
Thu Oct 1 14:13:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

osamu pushed a commit to branch multitar
in repository devscripts.

commit d5928f9e5a716d21e063dbf52bd0b1db586c4ea8
Author: Osamu Aoki <osamu at debian.org>
Date:   Thu Oct 1 22:12:13 2015 +0900

    uscan: match substring for dir walking
    
    Try to cope with popular structure
     archive/12.30/12.30.01/package-ver.tar.xz
---
 scripts/uscan.pl | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index 05f188d..1841a52 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -3384,8 +3384,14 @@ sub newest_dir ($$$$$) {
     my $base = $site.$dir;
     my ($request, $response);
     my $newdir;
+    my $download_version_short;
 
-    print STDERR "$progname debug: download version requested: $download_version\n" if $debug and defined $download_version; 
+    if (defined $download_version) {
+	print STDERR "$progname debug: download version requested: $download_version\n" if $debug;
+	if ($download_version =~ m/^(\w+\.\w+)\.\w+$/) {
+	    $download_version_short = "$1";
+	}
+    }
     if ($site =~ m%^http(s)?://%) {
 	if (defined($1) and !$haveSSL) {
 	    uscan_die "$progname: you must have the liblwp-protocol-https-perl package installed\nto use https URLs\n";
@@ -3434,11 +3440,17 @@ sub newest_dir ($$$$$) {
 			$match = "matched with the download version";
 		    }
 		}
+		if (defined $download_version_short) {
+		    if ($mangled_version eq $download_version_short) {
+			$match = "matched with the download version (partial)";
+		    }
+		}
 		push @hrefs, [$mangled_version, $href, $match];
 	    }
 	}
 	my @vhrefs = grep { $$_[2] } @hrefs;
 	if (@vhrefs) {
+	    @vhrefs = Devscripts::Versort::upstream_versort(@vhrefs);
 	    $newdir = $vhrefs[0][1];
 	}
 	if (@hrefs) {
@@ -3508,6 +3520,11 @@ sub newest_dir ($$$$$) {
 			$match = "matched with the download version";
 		    }
 		}
+		if (defined $download_version_short) {
+		    if ($mangled_version eq $download_version_short) {
+			$match = "matched with the download version (partial)";
+		    }
+		}
 		push @dirs, [$mangled_version, $dir, $match];
 	    }
 	} else {
@@ -3533,12 +3550,18 @@ sub newest_dir ($$$$$) {
 			    $match = "matched with the download version";
 			}
 		    }
+		    if (defined $download_version_short) {
+			if ($mangled_version eq $download_version_short) {
+			    $match = "matched with the download version (partial)";
+			}
+		    }
 		    push @dirs, [$mangled_version, $dir, $match];
 		}
 	    }
 	}
 	my @vdirs = grep { $$_[2] } @dirs;
 	if (@vdirs) {
+	    @vdirs = Devscripts::Versort::upstream_versort(@vdirs);
 	    $newdir = $vdirs[0][1];
 	}
 	if (@dirs) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list