compatibility: Treat empty version as unknown, not old.

This commit is contained in:
Greg Price
2018-12-04 15:06:46 -08:00
committed by Tim Abbott
parent ebfa4b746d
commit 1859faccb7
2 changed files with 6 additions and 1 deletions

View File

@@ -20,7 +20,10 @@ class VersionTest(ZulipTestCase):
15.1.95 < 16.2.96
16.2.96 = 16.2.96
20.0.103 > 16.2.96
'''.strip().split('\n')]
'''.strip().split('\n')] + [
['', '?', '1'],
['', '?', 'a'],
]
def test_version_lt(self) -> None:
for ver1, cmp, ver2 in self.data:

View File

@@ -31,6 +31,8 @@ def version_lt(ver1: str, ver2: str) -> Optional[bool]:
'''
num1, rest1 = pop_numerals(ver1)
num2, rest2 = pop_numerals(ver2)
if not num1 or not num2:
return None
common_len = min(len(num1), len(num2))
common_num1, rest_num1 = num1[:common_len], num1[common_len:]
common_num2, rest_num2 = num2[:common_len], num2[common_len:]