From afc89a0847131967743d2bb844e5686c3d6bf8ae Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Mon, 6 Jan 2025 16:56:28 +0800 Subject: [PATCH] Update version info of release (#2427) ### What problem does this PR solve? Current git in infinity-builder docker image doesn't 'first-parent'. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: Jin Hai --- CMakeLists.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3572f609fb..4467a7858f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,15 +68,25 @@ execute_process( OUTPUT_VARIABLE GIT_BRANCH_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( - COMMAND "${GIT_EXECUTABLE}" describe --tags --match=v* --first-parent --always - OUTPUT_VARIABLE GIT_COMMIT_ID + COMMAND "${GIT_EXECUTABLE}" describe --tags --abbrev=0 + OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-list --count "${GIT_TAG}..HEAD" + OUTPUT_VARIABLE COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD + OUTPUT_VARIABLE HEAD_COMMIT_ID + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(GIT_COMMIT_ID "${GIT_TAG}-${COMMIT_COUNT}-${HEAD_COMMIT_ID}") if("${GIT_BRANCH_NAME}" STREQUAL "") message(WARNING "Branch name not found.") else() message(STATUS "Branch name = ${GIT_BRANCH_NAME}") endif() -if("${GIT_COMMIT_ID}" STREQUAL "") +if("${HEAD_COMMIT_ID}" STREQUAL "") message(WARNING "Commit id not found.") else() message(STATUS "Commit-id = ${GIT_COMMIT_ID}")