[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#536404: [checks/watch] false positive debian-watch-file-should-mangle-version



Package: lintian
Version: 2.2.12
Severity: minor

From 363b26d99e73024be84d433334e7d24de2028772 Mon Sep 17 00:00:00 2001
From: Raphael Geissert <atomo64@gmail.com>
Date: Tue, 7 Jul 2009 23:47:23 -0500
Subject: [PATCH] Fix some false positives when detecting whether a watch file 
should mangle

The debian-watch-file-should-mangle-version check was not taking
whether an upstream version was specified in the watch file or not,
therefore producing false positives.
Additionally, the check was being run on a global scope, even when
multiple websites were being specified. This has been fixed and made
those checks indicate the offending lines.

Cheers,
-- 
Raphael Geissert - Debian Developer
www.debian.org - get.debian.net
From 363b26d99e73024be84d433334e7d24de2028772 Mon Sep 17 00:00:00 2001
From: Raphael Geissert <atomo64@gmail.com>
Date: Tue, 7 Jul 2009 23:47:23 -0500
Subject: [PATCH] Fix some false positives when detecting whether a watch file should mangle

The debian-watch-file-should-mangle-version check was not taking
whether an upstream version was specified in the watch file or not,
therefore producing false positives.
Additionally, the check was being run on a global scope, even when
multiple websites were being specified. This has been fixed and made
those checks indicate the offending lines.
---
 checks/watch-file                                  |   27 ++++++++++---------
 .../watch-file-should-mangle/debian/debian/watch   |    6 ++++
 t/tests/watch-file-should-mangle/tags              |    3 +-
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/checks/watch-file b/checks/watch-file
index c3292b1..25dbff4 100644
--- a/checks/watch-file
+++ b/checks/watch-file
@@ -52,7 +52,7 @@ if ($version =~ /(dfsg|debian|ds)/) {
 # diagnose on the first time through.
 open(WATCH, '<', 'debfiles/watch') or fail("cannot open watch file: $!");
 local $_;
-my ($watchver, $mangle, $dmangle, $nonempty, %dversions);
+my ($watchver, %dversions);
 while (<WATCH>) {
     next if /^\s*\#/;
     next if /^\s*$/;
@@ -76,7 +76,6 @@ while (<WATCH>) {
             tag 'debian-watch-file-unknown-version', $watchver;
         }
     } else {
-        $nonempty = 1;
 
         unless (defined($watchver)) {
             tag 'debian-watch-file-missing-version';
@@ -85,6 +84,7 @@ while (<WATCH>) {
         # Version 1 watch files are too broken to try checking them.
         next if ($watchver == 1);
 
+	my ($mangle, $dmangle) = (0, 0);
         my ($opts, @opts);
         if (s/^opt(?:ion)?s=\"([^\"]+)\"\s+// || s/^opt(?:ion)?s=(\S+)\s+//) {
             $opts = $1;
@@ -95,7 +95,7 @@ while (<WATCH>) {
                     $dmangle = 1 if /^dversionmangle\s*=.*($repack)/;
                 }
             }
-        }
+	}
         if (m%qa\.debian\.org/watch/sf\.php\?%) {
             tag 'debian-watch-file-uses-deprecated-sf-redirector-method',
                 "line $.";
@@ -117,20 +117,21 @@ while (<WATCH>) {
             (undef, $lastversion, $action) = split ' ', $_, 3;
         }
         push @{$dversions{$lastversion}}, $. if (defined($lastversion));
+        $lastversion = 'debian' unless (defined($lastversion));
+
+	my $needs_mangling = ($repack and $lastversion eq 'debian');
+        # If the version of the package contains dfsg, assume that it needs to be
+        # mangled to get reasonable matches with upstream.
+        if ($needs_mangling and not $mangle) {
+            tag 'debian-watch-file-should-mangle-version', "line $.";
+        }
+        if ($needs_mangling and $mangle and not $dmangle) {
+            tag 'debian-watch-file-should-dversionmangle-not-uversionmangle', "line $.";
+        }
     }
 }
 close WATCH;
 
-# If the version of the package contains dfsg, assume that it needs to be
-# mangled to get reasonable matches with upstream.
-if ($nonempty and $repack and not $mangle) {
-    tag 'debian-watch-file-should-mangle-version';
-}
-
-if ($repack and $mangle and not $dmangle) {
-    tag 'debian-watch-file-should-dversionmangle-not-uversionmangle';
-}
-
 my $changes = $info->changelog;
 if (defined $changes and %dversions) {
     my $data = $changes->data;
diff --git a/t/tests/watch-file-should-mangle/debian/debian/watch b/t/tests/watch-file-should-mangle/debian/debian/watch
index 92203ca..0032647 100644
--- a/t/tests/watch-file-should-mangle/debian/debian/watch
+++ b/t/tests/watch-file-should-mangle/debian/debian/watch
@@ -3,3 +3,9 @@
 
 version=2
 http://www.example.com/dist/ dh7-test\.([\d.]+)\.tar\.gz debian uupdate
+
+# version mangling is not needed in this case:
+http://www.example.com/dist/ dh7-test\.([\d.]+)\.tar\.gz 0.24 uupdate
+
+# version mangling *is* needed in this case:
+http://www.example.com/dist/ dh7-test\.([\d.]+)\.tar\.gz
diff --git a/t/tests/watch-file-should-mangle/tags b/t/tests/watch-file-should-mangle/tags
index 8e3a451..6be9d9e 100644
--- a/t/tests/watch-file-should-mangle/tags
+++ b/t/tests/watch-file-should-mangle/tags
@@ -1 +1,2 @@
-W: watch-file-should-mangle source: debian-watch-file-should-mangle-version
+W: watch-file-should-mangle source: debian-watch-file-should-mangle-version line 11
+W: watch-file-should-mangle source: debian-watch-file-should-mangle-version line 5
-- 
1.6.3.3


Reply to: