mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-06-20 04:44:12 -04:00
for version string, try to handle case where head is detached
This commit is contained in:
parent
3127e02cbb
commit
bef57e2819
1 changed files with 5 additions and 2 deletions
7
setup.py
7
setup.py
|
@ -8,12 +8,15 @@ VERSION_BYTES = b'0.2'
|
||||||
def full_version_bytes():
|
def full_version_bytes():
|
||||||
import subprocess, time
|
import subprocess, time
|
||||||
try:
|
try:
|
||||||
git_branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD'])
|
git_status = subprocess.check_output(['git', 'status'])
|
||||||
|
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_branch.strip() + b'-' + timestamp_utc.encode('utf-8')
|
return VERSION_BYTES + b'-' + git_head.strip() + b'-' + timestamp_utc.encode('utf-8')
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return VERSION_BYTES
|
return VERSION_BYTES
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue