Commit 4cadaedb authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

Add git hash in version for git version

parent d1eadcbc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+22 −0
Original line number Diff line number Diff line
@@ -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__ = []