Skip to content

Commit

Permalink
Fix version extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Feb 9, 2024
1 parent 4302c44 commit 5bbdc9e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CYD-Klipper/extract_commit.py
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down

0 comments on commit 5bbdc9e

Please sign in to comment.