Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit e467ace

Browse files
authored
Use correct version comparison in save_compatibility_statuses (#229)
1 parent 898abdd commit e467ace

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

compatibility_lib/compatibility_lib/compatibility_store.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Storage for package compatibility information."""
1616

1717
import datetime
18+
from distutils import version
1819
import enum
1920
import itertools
2021
import retrying
@@ -433,11 +434,12 @@ def save_compatibility_statuses(
433434
if install_name not in install_name_to_compatibility_result:
434435
install_name_to_compatibility_result[install_name] = cs
435436
else:
436-
old_version = self._get_package_version(
437+
old_version_string = self._get_package_version(
437438
install_name_to_compatibility_result[install_name])
438-
new_version = self._get_package_version(cs)
439-
# TODO: Do not compare versions lexicographically.
440-
# Lexicographically, '10' < '9'.
439+
new_version_string = self._get_package_version(cs)
440+
441+
old_version = version.StrictVersion(old_version_string)
442+
new_version = version.StrictVersion(new_version_string)
441443
if new_version > old_version:
442444
install_name_to_compatibility_result[install_name] = cs
443445

compatibility_lib/compatibility_lib/test_compatibility_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ def test_save_compatibility_statuses_release_time_for_latest(self):
425425
status=status,
426426
details=None,
427427
dependency_info={'package4': {
428-
'installed_version': '2.7.0',
428+
'installed_version': '12.7.0',
429429
'installed_version_time': '2018-05-12T16:26:31',
430-
'latest_version': '2.7.0',
430+
'latest_version': '12.7.0',
431431
'current_time': '2018-07-13T17:11:29.140608',
432432
'latest_version_time': '2018-05-12T16:26:31',
433433
'is_latest': True,
@@ -450,9 +450,9 @@ def test_save_compatibility_statuses_release_time_for_latest(self):
450450
row_release_time = {
451451
'install_name': 'package4[gcp]',
452452
'dep_name': 'package4',
453-
'installed_version': '2.7.0',
453+
'installed_version': '12.7.0',
454454
'installed_version_time': '2018-05-12T16:26:31',
455-
'latest_version': '2.7.0',
455+
'latest_version': '12.7.0',
456456
'timestamp': '2018-07-13T17:11:29.140608',
457457
'latest_version_time': '2018-05-12T16:26:31',
458458
'is_latest': True,

0 commit comments

Comments
 (0)