Fix CargoSemVer.eval_ KIND_GTE and KIND_LTE comparisons

Just make use of KIND_GT/KIND_LT and KIND_SHORTEQ

Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
This commit is contained in:
Michel Alexandre Salim 2022-10-31 12:54:37 -05:00
parent 1869f5a7e0
commit 6a5931b7dd
No known key found for this signature in database
GPG key ID: 8B229D2F7CCC04F2

View file

@ -166,9 +166,8 @@ class CargoSemVer:
)
elif op == CargoSemVer.KIND_GTE:
return (
(v1.major >= v2.major)
or (v1.major == v2.major and v1.minor >= v2.minor)
or (v1.major == v2.major and v1.minor == v2.minor and v1.patch >= v2.patch)
CargoSemVer.eval_(v1, CargoSemVer.KIND_GT, v2)
or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
)
elif op == CargoSemVer.KIND_LT:
return (
@ -178,9 +177,8 @@ class CargoSemVer:
)
elif op == CargoSemVer.KIND_LTE:
return (
(v1.major <= v2.major)
or (v1.major == v2.major and v1.minor <= v2.minor)
or (v1.major == v2.major and v1.minor == v2.minor and v1.patch <= v2.patch)
CargoSemVer.eval_(v1, CargoSemVer.KIND_LT, v2)
or CargoSemVer.eval_(v1, CargoSemVer.KIND_SHORTEQ, v2)
)
else:
raise ValueError(f"Cannot evaluate operator: {op}")