diff --git a/gramps/gen/const.py b/gramps/gen/const.py index ff9995ee1..4d034dabb 100644 --- a/gramps/gen/const.py +++ b/gramps/gen/const.py @@ -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 diff --git a/gramps/gen/svn_revision.py b/gramps/gen/git_revision.py similarity index 70% rename from gramps/gen/svn_revision.py rename to gramps/gen/git_revision.py index 0a33f8c82..20b726d3c 100644 --- a/gramps/gen/svn_revision.py +++ b/gramps/gen/git_revision.py @@ -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) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 52ed4da74..b2258b353 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -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 @@ -255,7 +256,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