Use git rev-parse instead, more robust

This commit is contained in:
Kovid Goyal 2018-04-01 20:33:06 +05:30
parent fa064bf9cf
commit 2efa83bc4d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -183,8 +183,7 @@ def init_env(
sysconfig.get_config_var('CCSHARED')
)
if os.path.exists('.git'):
head = open('.git/HEAD', 'r').read().split(':', 1)[-1].strip()
rev = open('.git/' + head).read().split(':', 1)[-1].strip()
rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
cflags.append('-DKITTY_VCS_REV="{}"'.format(rev))
ldflags = os.environ.get(
'OVERRIDE_LDFLAGS',