mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Fix version extractor
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
import subprocess
|
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()
|
git_describe_output = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True, check=True).stdout.strip()
|
||||||
split_output = git_describe_output.split("-")
|
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:
|
try:
|
||||||
data = extract_commit()
|
version = extract_commit()
|
||||||
version = f"{data[0]}\\ ({data[1]})"
|
|
||||||
except:
|
except:
|
||||||
version = "Unknown"
|
version = "Unknown"
|
||||||
|
|
||||||
|
|
||||||
flag = "-D REPO_VERSION=\\\"" + version + "\\\""
|
flag = "-D REPO_VERSION=\\\"" + version + "\\\""
|
||||||
print(f"Version: {version}")
|
print(f"Version: {version}")
|
||||||
print(f"Flag: {flag}")
|
print(f"Flag: {flag}")
|
||||||
|
|||||||
Reference in New Issue
Block a user