mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-26 21:33:05 +00:00
api_check_ipa_version: Fix version comparison for more than one digit
The fallback function used to compare IPA versions was spliting the version string into a tuple of strings, and the comparison of the tuple would fail if comparing a field with one digit aginst a two-digit one, for example, '8' with '10', as the string comparison would put '10' before the '8'. This patch forces the version fields to be converted to integers, so a numerical comparison will be performed. If a version string field cannot be converted to a number, than the string comparison will still be used.
This commit is contained in:
@@ -67,9 +67,15 @@ else:
|
||||
"""
|
||||
Split a version string A.B.C, into a tuple.
|
||||
|
||||
This will not work for `rc`, `dev` or similar version string.
|
||||
This will not work for `rc`, `dev` or similar.
|
||||
"""
|
||||
return tuple(re.split("[-_.]", version_str)) # noqa: W605
|
||||
try:
|
||||
_version = tuple(
|
||||
(int(x) for x in re.split("[-_.]", version_str))
|
||||
)
|
||||
except ValueError:
|
||||
_version = tuple(re.split("[-_.]", version_str))
|
||||
return _version
|
||||
|
||||
from ipalib import api
|
||||
from ipalib import errors as ipalib_errors # noqa
|
||||
|
||||
Reference in New Issue
Block a user