Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-25 23:44:48 +03:00
1 parent 639362fbf5
commit bdd69f0aad
101 files changed
+22691 -531

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""Validate one canonical Semantic Versioning 2.0.0 value."""
from __future__ import annotations
import re
import sys
SEMVER = re.compile(
r"^(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)"
r"(?:-((?:0|[1-9][0-9]*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)"
r"(?:\.(?:0|[1-9][0-9]*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*))?"
r"(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$"
)
def main() -> int:
if len(sys.argv) != 2:
print("usage: validate-semver.py VERSION", file=sys.stderr)
return 2
if not SEMVER.fullmatch(sys.argv[1]):
print(
f"validate-semver: version is not canonical SemVer: {sys.argv[1]!r}",
file=sys.stderr,
)
return 1
return 0
if __name__ == "__main__":
raise SystemExit(main())