Handle CI builds having a detached HEAD

This commit is contained in:
Asher Baker 2018-07-21 02:00:04 +01:00
parent d234f8f756
commit d7e3f11670

View File

@ -21,6 +21,14 @@ def GITHash():
return stdout.rstrip('\r\n')
def GITBranch():
travis_branch = os.environ.get('TRAVIS_BRANCH', False)
if travis_branch:
return travis_branch
appveyor_branch = os.environ.get('APPVEYOR_REPO_BRANCH', False)
if appveyor_branch:
return appveyor_branch
p = subprocess.Popen(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
(stdout, stderr) = p.communicate()
stdout = stdout.decode('UTF-8')