[SCM] Debian package checker branch, master, updated. 2.5.10-199-ga81a3b0
The following commit has been merged in the master branch:
commit b9d40094203e1845e76dce961e36914931850b54
Author: Bernhard R. Link <brlink@debian.org>
Date: Mon Jul 16 13:20:24 2012 +0200
c/fields: check vcs URLs for unexpected spaces
add %VCS_EXTRACT with subrotines to split a VCS-* field into
it's components. Warn against unaccounted spaces (i.e. currently
only allow one optional module with cvs, a mandatory module name
with monotone and an optional " -b " with git).
Signed-off-by: Bernhard R. Link <brlink@debian.org>
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/fields b/checks/fields
index 171139f..9905465 100644
--- a/checks/fields
+++ b/checks/fields
@@ -104,6 +104,20 @@ my @NAME_SECTION_MAPPINGS = (
[ qr/^lib.*-dev$/ => 'libdevel' ],
);
+my %VCS_EXTRACT = (
+ browser => sub { return @_;},
+ arch => sub { return @_;},
+ bzr => sub { return @_;},
+ # cvs rootdir followed by optional module name:
+ cvs => sub { return shift =~ /^(.+?)(?:\s+(\S*))?$/;},
+ darcs => sub { return @_;},
+ hg => sub { return @_;},
+ # git uri followed by optional " -b " + branchname:
+ git => sub { return shift =~ /^(.+?)(?:\s+-b\s+(\S*))?$/;},
+ svn => sub { return @_;},
+ # that's a hostname followed by a module name:
+ mtn => sub { return shift =~ /^(.+?)\s+(\S+)$/;},
+);
# Valid URI formats for the Vcs-* fields
# currently only checks the protocol, not the actual format of the URI
my %VCS_RECOMMENDED_URIS = (
@@ -115,7 +129,7 @@ my %VCS_RECOMMENDED_URIS = (
hg => qr;^https?://;,
git => qr;^(?:git|https?|rsync)://;,
svn => qr;^(?:svn|(?:svn\+)?https?)://;,
- mtn => qr;^[\w.-]+\s+\S+;, # that's a hostname followed by a module name
+ mtn => qr;^[\w.-]+$;,
);
my %VCS_VALID_URIS = (
arch => qr;^https?://;,
@@ -944,15 +958,23 @@ if (defined $info->field('dm-upload-allowed')) {
#----- Vcs-*
-while (my ($vcs, $regex) = each %VCS_RECOMMENDED_URIS) {
+while (my ($vcs, $splitter) = each %VCS_EXTRACT) {
if (defined $info->field("vcs-$vcs")) {
my $uri = $info->field("vcs-$vcs");
unfold("vcs-$vcs", \$uri);
- if ($uri !~ $regex) {
- if ($VCS_VALID_URIS{$vcs} and $uri =~ $VCS_VALID_URIS{$vcs}) {
- tag 'vcs-field-uses-not-recommended-uri-format', "vcs-$vcs", $uri;
- } else {
- tag 'vcs-field-uses-unknown-uri-format', "vcs-$vcs", $uri;
+ my @parts = &$splitter($uri);
+ if (not @parts or not $parts[0]) {
+ tag 'vcs-field-uses-unknown-uri-format', "vcs-$vcs", $uri;
+ } else {
+ if ($VCS_RECOMMENDED_URIS{$vcs} and $parts[0] !~ $VCS_RECOMMENDED_URIS{$vcs}) {
+ if ($VCS_VALID_URIS{$vcs} and $parts[0] =~ $VCS_VALID_URIS{$vcs}) {
+ tag 'vcs-field-uses-not-recommended-uri-format', "vcs-$vcs", $uri;
+ } else {
+ tag 'vcs-field-uses-unknown-uri-format', "vcs-$vcs", $uri;
+ }
+ }
+ if (grep { $_ and /\s/} @parts) {
+ tag 'vcs-field-has-unexpected-spaces', "vcs-$vcs", $uri;
}
}
}
diff --git a/checks/fields.desc b/checks/fields.desc
index cc4ed95..6795f2e 100644
--- a/checks/fields.desc
+++ b/checks/fields.desc
@@ -979,6 +979,14 @@ Certainty: possible
Info: The VCS-* field uses an URI which doesn't match any known format.
You might have forgotten the protocol before the hostname.
+Tag: vcs-field-has-unexpected-spaces
+Severity: normal
+Certainty: possible
+Info: The VCS-* field contains more spaces than expected or spaces at
+ places where they were not expected. Where possible escape valid spaces
+ in URIs to avoid any ambiguity with respect to possible future additional
+ optional fields.
+
Tag: lib-recommends-documentation
Severity: normal
Certainty: possible
diff --git a/t/tests/fields-malformed-vcs-fields/debian/debian/control.in b/t/tests/fields-malformed-vcs-fields/debian/debian/control.in
index 8b1b1a8..ba1e113 100644
--- a/t/tests/fields-malformed-vcs-fields/debian/debian/control.in
+++ b/t/tests/fields-malformed-vcs-fields/debian/debian/control.in
@@ -6,6 +6,7 @@ Standards-Version: {$standards_version}
Build-Depends: debhelper (>= 9)
Vcs-Browser: svn.debian.org/wsvn/foobar/trunk
Vcs-Svn: svn+ssh://svn.debian.org/svn/foobar/trunk
+Vcs-Git: git://anonscm.debian.org/test/test.git --branch wrong
Package: {$srcpkg}
Architecture: {$architecture}
diff --git a/t/tests/fields-malformed-vcs-fields/desc b/t/tests/fields-malformed-vcs-fields/desc
index 5157ddd..8dc829c 100644
--- a/t/tests/fields-malformed-vcs-fields/desc
+++ b/t/tests/fields-malformed-vcs-fields/desc
@@ -5,3 +5,4 @@ Version: 1.0
Test-For:
vcs-field-uses-not-recommended-uri-format
vcs-field-uses-unknown-uri-format
+ vcs-field-has-unexpected-spaces
diff --git a/t/tests/fields-malformed-vcs-fields/tags b/t/tests/fields-malformed-vcs-fields/tags
index 3fdeb6b..d7d432b 100644
--- a/t/tests/fields-malformed-vcs-fields/tags
+++ b/t/tests/fields-malformed-vcs-fields/tags
@@ -1,2 +1,3 @@
I: fields-malformed-vcs-fields source: vcs-field-uses-not-recommended-uri-format vcs-svn svn+ssh://svn.debian.org/svn/foobar/trunk
+W: fields-malformed-vcs-fields source: vcs-field-has-unexpected-spaces vcs-git git://anonscm.debian.org/test/test.git --branch wrong
W: fields-malformed-vcs-fields source: vcs-field-uses-unknown-uri-format vcs-browser svn.debian.org/wsvn/foobar/trunk
diff --git a/t/tests/fields-vcs-fields/debian/debian/control.in b/t/tests/fields-vcs-fields/debian/debian/control.in
index 0aa9a61..d942450 100644
--- a/t/tests/fields-vcs-fields/debian/debian/control.in
+++ b/t/tests/fields-vcs-fields/debian/debian/control.in
@@ -8,8 +8,8 @@ Vcs-Browser: https://svn.debian.org/wsvn/foobar/trunk
Vcs-Svn: svn://svn.debian.org/svn/foobar/trunk
Vcs-Mtn: www.example.org org.debian.foobar
Vcs-Hg: http://hg.debian.org/hg/foobar/pkg/foobar
-Vcs-Git: git://git.debian.org/git/users/djpig/foobar.git
-Vcs-Cvs: :pserver:anonymous@cvs.alioth.debian.org:/cvsroot/foobar
+Vcs-Git: git://anonscm.debian.org/users/djpig/foobar.git -b master
+Vcs-Cvs: :pserver:anonymous@anonscm.debian.org:/cvs/foobar module
Vcs-Bzr: nosmart+http://bzr.debian.org/bzr/collab-maint/foobar
Package: {$srcpkg}
diff --git a/t/tests/fields-vcs-fields/desc b/t/tests/fields-vcs-fields/desc
index 18e3d63..d112e3a 100644
--- a/t/tests/fields-vcs-fields/desc
+++ b/t/tests/fields-vcs-fields/desc
@@ -5,3 +5,4 @@ Version: 1.0
Test-Against:
vcs-field-uses-not-recommended-uri-format
vcs-field-uses-unknown-uri-format
+ vcs-field-has-unexpected-spaces
--
Debian package checker
Reply to: