[releng/alatiera/slightly-buggy-version-cmp: 3/3] try to emulate previous behavior
- From: Jordan Petridis <jpetridis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [releng/alatiera/slightly-buggy-version-cmp: 3/3] try to emulate previous behavior
- Date: Mon, 25 Jan 2021 06:54:49 +0000 (UTC)
commit bc98afd86a852b726bfeb7bc2e5a09edb9db48b9
Author: Jordan Petridis <jpetridis gnome org>
Date: Mon Jan 25 08:54:27 2021 +0200
try to emulate previous behavior
tools/smoketesting/downloadsites.py | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/tools/smoketesting/downloadsites.py b/tools/smoketesting/downloadsites.py
index 543eab0..2b99327 100644
--- a/tools/smoketesting/downloadsites.py
+++ b/tools/smoketesting/downloadsites.py
@@ -228,6 +228,28 @@ def version_cmp(a, b):
return cmp(len(A), len(B))
+
+def version_greater_or_equal_to_max(a, max_version) -> bool:
+ print(f"version: {a}, max_version: {max_version}")
+
+ if not max_version:
+ return False
+
+ res = version_cmp(a, max_version)
+ if res == 0:
+ # This doesn't ever run atm casue version_cmp treats 3.36.0 and 3.36 as equal
+ assert(False)
+ # FIXME: check for .0
+ return True
+ elif res == 1:
+ return True
+ elif res == -1:
+ return False
+ # This should never happen
+ else:
+ assert(False)
+
+
def get_latest_version(versions, max_version=None):
"""Gets the latest version number
@@ -237,6 +259,6 @@ def get_latest_version(versions, max_version=None):
versions = [ v.rstrip(os.path.sep) for v in versions ]
for version in versions:
if ( latest is None or version_cmp(version, latest) > 0 ) \
- and ( max_version is None or version_cmp(version, max_version) < 0 ):
+ and ( max_version is None or version_greater_or_equal_to_max(version, max_version) ):
latest = version
return latest
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]