btclock_v3/scripts/git_rev.py

21 lines
472 B
Python
Raw Normal View History

2023-11-07 20:26:15 +00:00
import subprocess
revision = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("utf-8")
)
2024-06-08 22:45:46 +00:00
try:
tag = (
subprocess.check_output(["git", "describe", "--tags", "--exact-match"])
.strip()
.decode("utf-8")
)
2024-06-08 23:07:04 +00:00
git_tag_define = '\'-DGIT_TAG=\"%s\"\'' % tag
2024-06-08 22:45:46 +00:00
except subprocess.CalledProcessError:
git_tag_define = ''
print("'-DGIT_REV=\"%s\"'" % revision)
if git_tag_define:
print(git_tag_define)