1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-27 07:06:13 +01:00

ArchQuery.epoch should never return None

Returning None breaks ArchQuery.vercmp. Returning b'0' is ok because
an epoch, if present, is always supposed to be an integer (at least
in a "valid" arch package (see scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
in the pacman sources)). Hence, if we compare the epoch of a package,
which has no explicit epoch set, with the epoch of a package, which
has an explicit epoch set, we always have a <= relation.
This commit is contained in:
Marcus Huewe 2019-01-27 15:39:07 +01:00
parent deee8ef6cb
commit 5c639db805

View File

@ -66,12 +66,12 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
return None
def epoch(self):
pkgver = self.fields['pkgver'][0] if 'pkgver' in self.fields else None
if pkgver != None:
pkgver = self.fields.get('pkgver', [b''])[0]
if pkgver:
m = re.match(r'([0-9])+:', pkgver)
if m:
return m.group(1)
return None
return b'0'
def arch(self):
return self.fields['arch'][0] if 'arch' in self.fields else None