Match git version with regex

Co-authored-by: Adrian Ho <the.gromgit@gmail.com>
This commit is contained in:
Chiller Dragon
2023-03-11 20:11:41 +01:00
committed by ChillerDragon
parent c699c94017
commit 41842df713

View File

@@ -383,8 +383,13 @@ test_git() {
fi
local git_version_output
git_version_output="$("$1" --version 2>/dev/null | awk '{ print $1 " " $2 " " $3 }')"
version_ge "$(major_minor "${git_version_output##* }")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
git_version_output="$("$1" --version 2>/dev/null)"
if [[ "${git_version_output}" =~ "git version "([^ ]*).* ]]
then
version_ge "$(major_minor "${BASH_REMATCH[1]}")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
else
abort "Unexpected Git version string '${git_version_output}' reported"
fi
}
# Search for the given executable in PATH (avoids a dependency on the `which` command)