root / snf-app / synnefo / version.py @ 450e0a22
History | View | Annotate | Download (960 Bytes)
1 |
VERSION = (0, 8, 0, 'alpha', 0) |
---|---|
2 |
__version__ = VERSION |
3 |
|
4 |
def get_version(): |
5 |
"""
|
6 |
Utility to parse version tuple to string
|
7 |
"""
|
8 |
version = '%s.%s' % (VERSION[0], VERSION[1]) |
9 |
if VERSION[2]: |
10 |
version = '%s.%s' % (version, VERSION[2]) |
11 |
if VERSION[3:] == ('alpha', 0): |
12 |
version = '%s pre-alpha' % version
|
13 |
else:
|
14 |
if VERSION[3] != 'final': |
15 |
version = '%s %s %s' % (version, VERSION[3], VERSION[4]) |
16 |
return version
|
17 |
|
18 |
def vcs_version(): |
19 |
"""
|
20 |
Return current git HEAD commit information
|
21 |
"""
|
22 |
import subprocess |
23 |
callgit = lambda(cmd): subprocess.Popen(
|
24 |
['/bin/sh', '-c', cmd], |
25 |
stdout=subprocess.PIPE).communicate()[0].strip()
|
26 |
|
27 |
branch = callgit('git branch | grep -Ei "\* (.*)" | cut -f2 -d" "')
|
28 |
revid = callgit("git --no-pager log --max-count=1 | cut -f2 -d' ' | head -1")
|
29 |
revno = callgit('git --no-pager log --oneline | wc -l')
|
30 |
|
31 |
return branch, revid, revno
|
32 |
|