Fix version extractor

This commit is contained in:
suchmememanyskill
2024-02-09 21:51:24 +01:00
parent 4302c4492c
commit 5bbdc9e509

View File

@@ -1,17 +1,19 @@
import subprocess
def extract_commit() -> tuple[str, str]: # Version, Commit
def extract_commit() -> str:
git_describe_output = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip()
split_output = git_describe_output.split("-")
return split_output[0], split_output[2][1:]
if (len(split_output) >= 3):
return f"{split_output[0]}\\ ({split_output[2][1:]})"
else:
return split_output[0]
try:
data = extract_commit()
version = f"{data[0]}\\ ({data[1]})"
version = extract_commit()
except:
version = "Unknown"
flag = "-D REPO_VERSION=\\\"" + version + "\\\""
print(f"Version: {version}")
print(f"Flag: {flag}")