fix commit number handling

This commit is contained in:
VintagePC 2023-09-11 18:53:20 -04:00
parent f1ab89183d
commit 2b5e2dc9fe
2 changed files with 7 additions and 3 deletions

View File

@ -46,7 +46,7 @@ message(STATUS "Project version description......: ${PROJECT_VERSION_FULL}")
# testing
# SET(FW_COMMIT_DSC "v3.13.0-1234")
if(NOT "${PROJECT_VERSION_SUFFIX}" STREQUAL "UNKNOWN" AND NOT "${FW_COMMIT_DSC}" MATCHES ".+NOTFOUND\$") # else -> no commit hash is known... likely no git.
if(NOT "${PROJECT_VERSION_SUFFIX}" STREQUAL "UNKNOWN" AND NOT "${FW_COMMIT_DSC}" MATCHES ".+NOTFOUND.+") # else -> no commit hash is known... likely no git.
string(REGEX MATCH "v([0-9]+)\.([0-9]+)\.([0-9]+)-?(${DEV_TAG_REGEX})?([0-9]+)?-([0-9]+)" TAG_VERSION "${FW_COMMIT_DSC}")
if (CMAKE_MATCH_4) # Do we have a build type?

View File

@ -231,7 +231,7 @@ function(git_describe_working_tree _var)
endif()
git_head_commit_number(COMMIT_COUNT) #Bake the commit count into the full DSC
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --abbrev=0 --dirty=-${COMMIT_COUNT}-D --broken=-B ${ARGN}
COMMAND "${GIT_EXECUTABLE}" describe --abbrev=0 --dirty=-D --broken=-B ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
@ -239,7 +239,11 @@ function(git_describe_working_tree _var)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
if( "${out}" MATCHES "-D\$")
STRING(REPLACE "-D" "-${COMMIT_COUNT}-D" out "${out}")
else()
set(out "${out}-${COMMIT_COUNT}")
endif()
set(${_var}
"${out}"
PARENT_SCOPE)