ddnet/scripts/git_revision.py

10 lines
333 B
Python
Raw Normal View History

import subprocess
try:
git_hash = subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=subprocess.DEVNULL).decode().strip()
definition = f'"{git_hash}"'
except FileNotFoundError:
definition = "0"
except subprocess.CalledProcessError:
2020-12-02 14:22:26 +00:00
definition = "0"
print(f"const char *GIT_SHORTREV_HASH = {definition};")