File: git_revision.py

package info (click to toggle)
ddnet 19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,960 kB
  • sloc: cpp: 195,050; ansic: 58,572; python: 5,568; asm: 946; sh: 941; java: 366; xml: 206; makefile: 31
file content (12 lines) | stat: -rw-r--r-- 422 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
import os
import subprocess
git_hash = os.environ.get("DDNET_GIT_SHORTREV_HASH")
try:
	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:
	definition = f'"{git_hash}"'
else:
	definition = "0"
print(f"const char *GIT_SHORTREV_HASH = {definition};")