Commit dd791373 authored by Chandan Singh's avatar Chandan Singh Committed by Chandan Singh
Browse files

testutils/site.py: Support parsing more exotic git versions

We use output of `git --version` to determine if we can run some tests
that rely on features from newer git versions. Usually, we expect the
output to be like:

    git version 2.17.2

On some platforms, like MacOS, there could be a suffix after the version
string, so that it looks something like:

    git version 2.17.2 (Apple Git-113)

This causes things to fail like so:

    ValueError: invalid literal for int() with base 10: '2 (Apple Git-113)\n'

Fix logic around `HAVE_OLD_GIT` such that we split the output of
`git --version` without limit on how many times we split. Previously we
used to split only twice so the suffixes like `(Apple Git-113)` are not
part of the parsed version.
parent fa4a21ce
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ try:
    utils.get_host_tool('git')
    utils.get_host_tool('git')
    HAVE_GIT = True
    HAVE_GIT = True
    out = str(subprocess.check_output(['git', '--version']), "utf-8")
    out = str(subprocess.check_output(['git', '--version']), "utf-8")
    version = tuple(int(x) for x in out.split(' ', 2)[2].split('.'))
    version = tuple(int(x) for x in out.split(' ')[2].split('.'))
    HAVE_OLD_GIT = version < (1, 8, 5)
    HAVE_OLD_GIT = version < (1, 8, 5)
except ProgramNotFoundError:
except ProgramNotFoundError:
    HAVE_GIT = False
    HAVE_GIT = False