TRX/tools/shared/versioning.py

23 lines
490 B
Python
Raw Normal View History

2024-04-10 10:26:06 +02:00
from subprocess import check_output
def get_branch_version(branch: str | None) -> str:
return check_output(
[
"git",
"describe",
*([branch] if branch else ["--dirty"]),
"--always",
"--abbrev=7",
"--tags",
"--exclude",
"latest",
],
text=True,
).strip()
2024-03-25 11:09:05 +01:00
def generate_version() -> str:
2024-04-10 10:26:06 +02:00
version = get_branch_version(None)
2024-03-25 11:09:05 +01:00
return f'TR1X {version or "?"}'