fix(api): allow single digit version for legacy schema
This commit is contained in:
parent
4ada25a3ff
commit
3d124eba7e
|
@ -23,7 +23,10 @@ def parse_version(version: str):
|
||||||
if not match:
|
if not match:
|
||||||
raise Exception(f"invalid version {version}")
|
raise Exception(f"invalid version {version}")
|
||||||
|
|
||||||
major, minor, patch = map(int, match.group("release").split("."))
|
release = list(map(int, match.group("release").split(".")))
|
||||||
|
major = release.pop(0) if release else 0
|
||||||
|
minor = release.pop(0) if release else 0
|
||||||
|
patch = release.pop(0) if release else 0
|
||||||
|
|
||||||
pre_mapping = {"alpha": -2, "beta": -1, None: 0, "": 0}
|
pre_mapping = {"alpha": -2, "beta": -1, None: 0, "": 0}
|
||||||
pre = pre_mapping[match.group("pre_l")]
|
pre = pre_mapping[match.group("pre_l")]
|
||||||
|
|
|
@ -14,6 +14,8 @@ from ...migrations._version import parse_version
|
||||||
("3.0.0-beta.10", (3, 0, 0, -1, 10, 0)),
|
("3.0.0-beta.10", (3, 0, 0, -1, 10, 0)),
|
||||||
("2.5.2", (2, 5, 2, 0, 0, 0)),
|
("2.5.2", (2, 5, 2, 0, 0, 0)),
|
||||||
("3.0.0", (3, 0, 0, 0, 0, 0)),
|
("3.0.0", (3, 0, 0, 0, 0, 0)),
|
||||||
|
("3.0", (3, 0, 0, 0, 0, 0)),
|
||||||
|
("3", (3, 0, 0, 0, 0, 0)),
|
||||||
# fmt: on
|
# fmt: on
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -35,6 +37,8 @@ def test_parse_version(version: str, expected):
|
||||||
("3.0.0", "4.0.0"),
|
("3.0.0", "4.0.0"),
|
||||||
("2.5.3", "3.0.0"),
|
("2.5.3", "3.0.0"),
|
||||||
("3.0.0", "3.0.0"),
|
("3.0.0", "3.0.0"),
|
||||||
|
("3.0", "3.1"),
|
||||||
|
("3", "4"),
|
||||||
# fmt: on
|
# fmt: on
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue