INNER CODE UNIT · Python

normalized_version

zhinkgit/embeddedskills · .github/maintenance/package_release.py:19

def normalized_version(root: Path, requested: str | None) -> str:
    version = requested
    if not version:
        process = subprocess.run(
            ["git", "describe", "--tags", "--always", "--dirty"],
            cwd=root,
            text=True,
            capture_output=True,
            check=True,
        )
        version = process.stdout.strip()
    version = version.removeprefix("v")
    return validate_version(version)


def validate_version(version: str) -> str:
    if not re.fullmatch(r"[0-9A-Za-z][0-9A-Za-z._-]*", version):
        raise ValueError(f"invalid release version: {version!r}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…