aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-07-04 19:40:35 +0200
committerGuido Günther <agx@sigxcpu.org>2017-07-06 08:54:17 +0200
commit0388f9e397e591cd4de7de019e54d10548049943 (patch)
treeebc57fb031230a3528d175739b74eba026639f2b
parent4e6dd9c05681e888f1805eadd57cc70b639efd3f (diff)
uscan: Always raise an error if we find <error/> or <warning/>
uscan does not abort with a non-zero exit status when it fails to verify gpg signatures or similar things so abort when we find a warning or error. We can't do any better since uscan stops further processing in this case of e.g. pgp errors skipping version mangle among other things. See #841910.
-rw-r--r--gbp/deb/uscan.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/gbp/deb/uscan.py b/gbp/deb/uscan.py
index 4613b96..bd742c7 100644
--- a/gbp/deb/uscan.py
+++ b/gbp/deb/uscan.py
@@ -129,7 +129,7 @@ class Uscan(object):
else:
self._uptodate = False
- def _raise_error(self, out):
+ def _maybe_raise_error(self, out):
r"""
Parse the uscan output for errors and warnings and raise
a L{UscanError} exception based on this. If no error detail
@@ -140,7 +140,7 @@ class Uscan(object):
@raises UscanError: exception raised
>>> u = Uscan('http://example.com/')
- >>> u._raise_error("<warnings>uscan warning: "
+ >>> u._maybe_raise_error("<warnings>uscan warning: "
... "In watchfile debian/watch, reading webpage\n"
... "http://a.b/ failed: 500 Cant connect "
... "to example.com:80 (Bad hostname)</warnings>")
@@ -148,15 +148,16 @@ class Uscan(object):
...
UscanError: Uscan failed: uscan warning: In watchfile debian/watch, reading webpage
http://a.b/ failed: 500 Cant connect to example.com:80 (Bad hostname)
- >>> u._raise_error("<errors>uscan: Can't use --verbose if "
+ >>> u._maybe_raise_error("<errors>uscan: Can't use --verbose if "
... "you're using --dehs!</errors>")
Traceback (most recent call last):
...
UscanError: Uscan failed: uscan: Can't use --verbose if you're using --dehs!
- >>> u = u._raise_error('')
+ >>> u._maybe_raise_error("<warnings>OpenPGP signature did not verify.</warnings>")
Traceback (most recent call last):
...
- UscanError: Uscan failed - debug by running 'uscan --verbose'
+ UscanError: Uscan failed: OpenPGP signature did not verify.
+ >>> u._maybe_raise_error('doesnotmatter')
"""
msg = None
@@ -165,10 +166,8 @@ class Uscan(object):
if m:
msg = "Uscan failed: %s" % m.group(1)
break
-
- if not msg:
- msg = "Uscan failed - debug by running 'uscan --verbose'"
- raise UscanError(msg)
+ if msg:
+ raise UscanError(msg)
def scan(self, destdir='..'):
"""Invoke uscan to fetch a new upstream version"""
@@ -181,9 +180,9 @@ class Uscan(object):
# Don't fail in the uptodate case:
self._parse_uptodate(out)
if not self.uptodate:
+ self._maybe_raise_error(out)
if p.returncode:
- self._raise_error(out)
- else:
- self._parse(out)
+ raise UscanError("Uscan failed - debug by running 'uscan --verbose'")
+ self._parse(out)
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: