def git_version():
'''Return the git revision as a string
Returns
-------
git_version : str
The current git revision
'''
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
output = subprocess.check_output(cmd,
stderr=subprocess.DEVNULL,
env=env)
return output
try:
out = _minimal_ext_cmd(['git', 'rev-parse', '--verify', '--quiet', '--short', 'HEAD'])
GIT_REVISION = out.strip().decode('ascii')
except subprocess.CalledProcessError:
GIT_REVISION = 'UNKNOWN'
return GIT_REVISION
评论列表
文章目录