build: ensure version generation always succeeds (#19515)

Add --always flag to `git describe` so version generation succeeds if
current directory is in a git repo. If not in git repo, fall back to a
default version in the format vx.y.z-dev
This commit is contained in:
dundargoc 2022-09-10 14:37:11 +02:00 committed by GitHub
parent 4638fcf4fb
commit 2a1c65b330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,15 +7,11 @@ set(NVIM_VERSION_MEDIUM
"v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}${NVIM_VERSION_PRERELEASE}") "v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}${NVIM_VERSION_PRERELEASE}")
execute_process( execute_process(
COMMAND git describe --first-parent --dirty COMMAND git describe --first-parent --dirty --always
OUTPUT_VARIABLE GIT_TAG OUTPUT_VARIABLE GIT_TAG
ERROR_VARIABLE ERR RESULT_VARIABLE RES)
RESULT_VARIABLE RES
)
if(NOT RES EQUAL 0) if(RES AND NOT RES EQUAL 0)
message(STATUS "Git tag extraction failed:\n" " ${GIT_TAG}${ERR}" )
# This will only be executed once since the file will get generated afterwards.
message(STATUS "Using NVIM_VERSION_MEDIUM: ${NVIM_VERSION_MEDIUM}") message(STATUS "Using NVIM_VERSION_MEDIUM: ${NVIM_VERSION_MEDIUM}")
file(WRITE "${OUTPUT}" "${NVIM_VERSION_STRING}") file(WRITE "${OUTPUT}" "${NVIM_VERSION_STRING}")
return() return()