osdict: adapt latest_regex() to openSUSE's versioning

Due to OpenSUSE's decision of versioning their OS as 11.x, 12.x, 42.x,
15.x, we have to add a specific check in latest_regex() in order to make
sure we skip the 42.x series in the sorted list of OSes when returning
the OS name to the user.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio
2018-11-23 16:07:26 +01:00
committed by Pavel Hrdina
parent 7612c5bdcd
commit fbcea0b63c

View File

@ -238,6 +238,15 @@ class _OSDB(object):
oses = [o.name for o in self.list_os() if re.match(regex, o.name)]
if not oses:
return None
# OpenSUSE's decision of having their versioning as 11.x, 12.x, 42.x,
# 15.x forces us to have this specific check for then.
# Knowing that 42 series was composed of 42.[1-3] and that the series
# will not have any more release, we can safely return the 4th element
# of the oses.
if regex.startswith("opensuse"):
return oses[3]
return oses[0]
def latest_os_version(self, osdistro):