Change version string to contain git hash instead of svn revision

This commit is contained in:
Nick Hall 2013-11-08 19:44:15 +00:00
parent 63578d95a0
commit 57daf4f269
3 changed files with 8 additions and 21 deletions

View File

@ -43,7 +43,7 @@ import uuid
# Gramps modules
#
#-------------------------------------------------------------------------
from .svn_revision import get_svn_revision
from .git_revision import get_git_revision
#-------------------------------------------------------------------------
#
@ -145,7 +145,7 @@ if sys.version_info[0] < 3:
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
unicode(__file__, sys.getfilesystemencoding())), os.pardir))
VERSION += get_svn_revision(ROOT_DIR)
VERSION += get_git_revision(ROOT_DIR)
#
# Glade files

View File

@ -25,7 +25,6 @@ from __future__ import unicode_literals
import sys
import subprocess
import re
if sys.version_info[0] < 3:
cuni = unicode
@ -34,12 +33,13 @@ else:
return s.decode("utf-8", errors = 'replace')
cuni = to_utf8
def _get_svn_revision(path, command, stdout_to_rev):
def get_git_revision(path=""):
stdout = ""
command = "git log -1 --format=%h"
try:
p = subprocess.Popen(
"{} \"{}\"".format(command, path),
shell=True,
shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
except:
@ -50,19 +50,6 @@ def _get_svn_revision(path, command, stdout_to_rev):
stdout = cuni(stdout) # get a proper string
except UnicodeDecodeError:
pass
rev = stdout_to_rev(stdout)
return "-r" + rev if rev else ""
else: # no output from svnversion
return "-" + stdout if stdout else ""
else: # no output from git log
return ""
def get_svn_revision(path=""):
return _get_svn_revision(path, "svnversion -n",
lambda stdout: stdout if stdout[0].isdigit() else ""
) or get_git_svn_revision(path)
def get_git_svn_revision(path=""):
def stdout_to_rev(stdout):
m = re.search("Revision:\s+(\d+)", stdout, re.MULTILINE)
return m.group(1) if m else ""
return _get_svn_revision(path, "git svn info", stdout_to_rev)

View File

@ -15,6 +15,7 @@ gramps/cli/__init__.py
gramps/gen/constfunc.py
gramps/gen/dbstate.py
gramps/gen/errors.py
gramps/gen/git_revision.py
gramps/gen/__init__.py
gramps/gen/recentfiles.py
gramps/gen/sort.py
@ -253,7 +254,6 @@ gramps/gen/utils/file.py
gramps/gen/utils/id.py
gramps/gen/utils/libformatting.py
gramps/gen/utils/mactrans.py
gramps/gen/utils/svn.py
gramps/gen/utils/test/callback_test.py
#
# gen.utils.docgen