forked from mcedit/mcedit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
38 lines (31 loc) · 1 KB
/
release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os.path
import subprocess
import directories
def get_version():
"""
Loads the build version from the bundled version file, if available.
"""
if not os.path.exists(os.path.join(directories.dataDir, 'RELEASE-VERSION')):
try:
return subprocess.check_output('git describe --tags --match=*.*.*'.split()).strip()
except:
return 'unknown'
fin = open(os.path.join(directories.dataDir, 'RELEASE-VERSION'), 'rb')
v = fin.read().strip()
fin.close()
return v
def get_commit():
"""
Loads the git commit ID from the bundled version file, if available.
"""
if not os.path.exists(os.path.join(directories.dataDir, 'GIT-COMMIT')):
try:
return subprocess.check_output('git rev-parse HEAD'.split()).strip()
except:
return 'unknown'
fin = open(os.path.join(directories.dataDir, 'GIT-COMMIT'), 'rb')
v = fin.read().strip()
fin.close()
return v
release = get_version()
commit = get_commit()