Skip to content

Commit

Permalink
fix commit number handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagepc committed Sep 11, 2023
1 parent f1ab891 commit 2b5e2dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
8 changes: 6 additions & 2 deletions cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,19 @@ 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
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
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)
Expand Down

0 comments on commit 2b5e2dc

Please sign in to comment.