Skip to content

Commit c35711e

Browse files
committed
chore: allow versionstrings with v prefix to be treated as version
Previously only versions on format X.Y.Z was allowed, all other version strings would be treated as version 0.0.0. Now vX.Y.Z is also allowed. Refs: equinor/ecalc-internal#915
1 parent 4d5dd0b commit c35711e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/libecalc/common/version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def from_string(cls, version_string: str | None) -> "Version":
2929
if version_string is None:
3030
return cls()
3131

32+
if version_string.lower().startswith("v"):
33+
version_string = version_string[1:]
34+
3235
pattern = re.compile(VERSION_FORMAT)
3336
match = pattern.match(version_string)
3437

tests/libecalc/common/test_version.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
("100", Version(100, 0, 0)),
1717
("0", Version(0, 0, 0)),
1818
("0.1.2", Version(0, 1, 2)),
19+
("v1.1.1", Version(1, 1, 1)),
20+
("v2025.10.0", Version(2025, 10, 0)),
21+
("v2025.10.10", Version(2025, 10, 10)),
22+
("master", Version(0, 0, 0)),
23+
("master-latest", Version(0, 0, 0)),
1924
]
2025

2126

0 commit comments

Comments
 (0)