Skip to content

Commit b3d2b96

Browse files
committed
Update version comparison logic to handle development versions correctly
1 parent 040cc5b commit b3d2b96

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cdlclient/remote.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,27 @@ def is_version_at_least(version1: str, version2: str) -> bool:
204204
205205
Returns:
206206
bool: True if version1 is greater than or equal to version2, False otherwise.
207+
208+
.. note::
209+
210+
Development, alpha, beta, and rc versions are considered to be equal
211+
to the corresponding release version.
207212
"""
208213
# Split the version strings into parts
209-
parts1 = [int(part) for part in version1.split(".")]
210-
parts2 = [int(part) for part in version2.split(".")]
214+
parts1 = [part.strip() for part in version1.split(".")]
215+
parts2 = [part.strip() for part in version2.split(".")]
211216

212-
# Compare each part
213217
for part1, part2 in zip(parts1, parts2):
214-
if part1 > part2:
218+
if part1.isdigit() and part2.isdigit():
219+
if int(part1) > int(part2):
220+
return True
221+
elif int(part1) < int(part2):
222+
return False
223+
elif part1 > part2:
215224
return True
216225
elif part1 < part2:
217226
return False
218227

219-
# Check if version1 is shorter and thus less than version2
220228
return len(parts1) >= len(parts2)
221229

222230

0 commit comments

Comments
 (0)