ddnet/scripts/git_revision.py
def 7379a64004 [WIP] Require Python 3.6 (f-strings) and fix pylints
So far only done scripts directory, will do the rest if this is
considered good
2022-07-27 09:37:24 +02:00

13 lines
388 B
Python

import errno
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 as e:
if e.errno != errno.ENOENT:
raise
definition = "0"
except subprocess.CalledProcessError:
definition = "0"
print(f"const char *GIT_SHORTREV_HASH = {definition};")