for the version string, use abbreviated commit hash instead of attempting to use the branch name

This commit is contained in:
Noah Levitt 2014-05-29 23:33:14 -07:00
parent bef57e2819
commit ed92f3bd53

View file

@ -8,15 +8,13 @@ VERSION_BYTES = b'0.2'
def full_version_bytes(): def full_version_bytes():
import subprocess, time import subprocess, time
try: try:
git_status = subprocess.check_output(['git', 'status']) commit_bytes = subprocess.check_output(['git', 'log', '-1', '--pretty=format:%h'])
line1 = git_status[:git_status.find(b'\n')]
git_head = line1.split()[-1]
t_bytes = subprocess.check_output(['git', 'log', '-1', '--pretty=format:%ct']) t_bytes = subprocess.check_output(['git', 'log', '-1', '--pretty=format:%ct'])
t = int(t_bytes.strip().decode('utf-8')) t = int(t_bytes.strip().decode('utf-8'))
tm = time.gmtime(t) tm = time.gmtime(t)
timestamp_utc = time.strftime("%Y%m%d%H%M%S", time.gmtime(t)) timestamp_utc = time.strftime("%Y%m%d%H%M%S", time.gmtime(t))
return VERSION_BYTES + b'-' + git_head.strip() + b'-' + timestamp_utc.encode('utf-8') return VERSION_BYTES + b'-' + timestamp_utc.encode('utf-8') + b'-' + commit_bytes.strip()
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
return VERSION_BYTES return VERSION_BYTES