From 4cadaedbc5a4771b40f54972d56a31a26522777d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Wed, 19 Jun 2013 12:01:45 +0200 Subject: [PATCH] Add git hash in version for git version --- configure.ac | 3 +++ installsystems/__init__.py.in | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 014495c..898cedd 100644 --- a/configure.ac +++ b/configure.ac @@ -37,4 +37,7 @@ AC_SUBST([zshcompdir], [$with_zshcompdir]) AC_PROG_SED +AM_CONDITIONAL([ISGIT],[test -d .git]) +AM_COND_IF([ISGIT],[VERSION=$VERSION+git]) + AC_OUTPUT diff --git a/installsystems/__init__.py.in b/installsystems/__init__.py.in index 7c2757c..1b868ec 100644 --- a/installsystems/__init__.py.in +++ b/installsystems/__init__.py.in @@ -24,4 +24,26 @@ canonical_name="installsystems" version = "@VERSION@" verbosity = 1 # 0: quiet, 1: normal, 2: debug +def git_version(): + import os + import sys + from subprocess import check_output, CalledProcessError + version = "" + cwd = os.getcwd() + try: + os.chdir(os.path.dirname(sys.argv[0])) + version = check_output(["git", "describe", "--tags", "--always" ], + stdin=open(os.devnull, 'rb'), + stderr=open(os.devnull, "wb")).strip() + if len(version) > 0: + version = "-" + version + except (OSError, CalledProcessError): + pass + finally: + os.chdir(cwd) + return version + +if version.find("+git") >= 0: + version += git_version() + __all__ = [] -- GitLab