Correctly add GIT_COMMIT_HASH into version string:

Commit bf013c02ad added support
for incorporating a commit ID into the compiled version string
but did so in a way that did not follow the semantic versioning
standard.

This commit corrects that flaw by moving the commit ID into the
"metadata" part of the version string and properly handles the
case where the commit hash cannot be retrieved.
This commit is contained in:
Edward Hennis
2022-01-06 10:47:22 -05:00
committed by Nik Bougalis
parent 289bc0afd9
commit d23d37fcfd
2 changed files with 10 additions and 6 deletions

View File

@@ -10,9 +10,12 @@ project (rippled)
find_package(Git)
if(Git_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=40
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GIT_COMMIT_HASH)
message(STATUS gch: ${GIT_COMMIT_HASH})
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gch)
if(gch)
set(GIT_COMMIT_HASH "${gch}")
message(STATUS gch: ${GIT_COMMIT_HASH})
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
endif()
endif() #git
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake")

View File

@@ -37,10 +37,11 @@ char const* const versionString = "1.8.4"
// clang-format on
#if defined(DEBUG) || defined(SANITIZER)
#ifdef GIT_COMMIT_HASH
"-" GIT_COMMIT_HASH
#endif
"+"
#ifdef GIT_COMMIT_HASH
GIT_COMMIT_HASH
"."
#endif
#ifdef DEBUG
"DEBUG"
#ifdef SANITIZER