get version from git

This commit is contained in:
j 2015-09-24 11:46:33 +01:00
parent 01fc5ad40f
commit 97bbd595bd

View file

@ -9,9 +9,17 @@ except:
def get_bzr_version(): def get_bzr_version():
import os import os
import re import re
import subprocess
dot_git = os.path.join(os.path.dirname(__file__), '.git')
info = os.path.join(os.path.dirname(__file__), '.bzr/branch/last-revision') info = os.path.join(os.path.dirname(__file__), '.bzr/branch/last-revision')
changelog = os.path.join(os.path.dirname(__file__), 'debian/changelog') changelog = os.path.join(os.path.dirname(__file__), 'debian/changelog')
if os.path.exists(info): if os.path.exists(dot_git):
cmd = ['git', 'rev-list', 'HEAD', '--count']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
rev = int(stdout)
return u'%s' % rev
elif os.path.exists(info):
f = open(info) f = open(info)
rev = int(f.read().split()[0]) rev = int(f.read().split()[0])
f.close() f.close()