File: git_revision.py

package info (click to toggle)
teeworlds 0.7.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,068 kB
  • sloc: cpp: 58,010; ansic: 14,468; python: 3,763; asm: 946; objc: 107; makefile: 36; xml: 21; sh: 7
file content (21 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import errno
import subprocess
try:
	from subprocess import DEVNULL
except ImportError:
	import os
	DEVNULL = open(os.devnull, 'wb')
try:
	FileNotFoundError
except NameError:
	FileNotFoundError = OSError
try:
	git_hash = subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=DEVNULL).decode().strip()
	definition = '"{}"'.format(git_hash)
except FileNotFoundError as e:
	if e.errno != errno.ENOENT:
		raise
	definition = "0"
except subprocess.CalledProcessError:
	definition = "0";
print("const char *GIT_SHORTREV_HASH = {};".format(definition))