proper handling for git sha hash
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-02-07 19:37:23 +01:00
parent 5f81b0866a
commit 2580b7cb20
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 9 additions and 3 deletions

View File

@ -171,7 +171,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
list(GET GIT_INFO 1 OBSW_VERSION_MAJOR)
list(GET GIT_INFO 2 OBSW_VERSION_MINOR)
list(GET GIT_INFO 3 OBSW_VERSION_REVISION)
list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1)
list(LENGTH GIT_INFO LIST_LEN)
if(LIST_LEN GREATER 4)
list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1)
endif()
if(NOT OBSW_VERSION_MAJOR)
set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS})
endif()

View File

@ -4,7 +4,7 @@
# 2. Major version
# 3. Minor version
# 4. Revision
# 5. git SHA hash and commits since tag
# 5. (Optional) git SHA hash and commits since tag when applicable
function(determine_version_with_git)
include(GetGitRevisionDescription)
git_describe(VERSION ${ARGN})
@ -22,7 +22,10 @@ function(determine_version_with_git)
list(APPEND GIT_INFO ${_VERSION_MAJOR})
list(APPEND GIT_INFO ${_VERSION_MINOR})
list(APPEND GIT_INFO ${_VERSION_PATCH})
list(APPEND GIT_INFO ${VERSION_SHA1})
if(NOT VERSION_SHA1 STREQUAL VERSION)
list(APPEND GIT_INFO ${VERSION_SHA1})
endif()
set(GIT_INFO ${GIT_INFO} PARENT_SCOPE)
message(STATUS "GIT INFO: ${GIT_INFO}")
message(STATUS "eive | Set git version info into GIT_INFO from the git tag ${VERSION}")
endfunction()