2023-03-19 16:13:58 +00:00
|
|
|
import os
|
2018-03-01 15:50:29 +00:00
|
|
|
import subprocess
|
2023-03-19 16:13:58 +00:00
|
|
|
git_hash = os.environ.get("DDNET_GIT_SHORTREV_HASH")
|
2018-03-02 02:31:45 +00:00
|
|
|
try:
|
2023-03-19 16:13:58 +00:00
|
|
|
git_hash = git_hash or subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=subprocess.DEVNULL).decode().strip()
|
|
|
|
except (FileNotFoundError, subprocess.CalledProcessError):
|
|
|
|
pass
|
|
|
|
if git_hash is not None:
|
2022-06-12 11:15:02 +00:00
|
|
|
definition = f'"{git_hash}"'
|
2023-03-19 16:13:58 +00:00
|
|
|
else:
|
2020-12-02 14:22:26 +00:00
|
|
|
definition = "0"
|
2022-06-12 11:15:02 +00:00
|
|
|
print(f"const char *GIT_SHORTREV_HASH = {definition};")
|