diff --git a/CYD-Klipper/extract_commit.py b/CYD-Klipper/extract_commit.py index 106d4bb..e8f1e52 100644 --- a/CYD-Klipper/extract_commit.py +++ b/CYD-Klipper/extract_commit.py @@ -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}")