From 57a5488ac2d0848986cb8ab30f07c6a59e5175d6 Mon Sep 17 00:00:00 2001 From: Jonathan Rubenstein Date: Tue, 8 Dec 2020 11:00:40 -0500 Subject: [PATCH] [cmake] replace git diff logic with git describe --dirty The --dirty argument of git describe performs the same function as the now-removed git diff logic. It will add its argument (default '-dirty') to the end of the revision. Providing '+' as the argument replicates old behavior. --- version.cmake | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/version.cmake b/version.cmake index 4bccd332..0559ac29 100644 --- a/version.cmake +++ b/version.cmake @@ -1,26 +1,18 @@ execute_process( - COMMAND git describe --always --long --abbrev=10 --tags + COMMAND git describe --always --long --abbrev=10 --dirty=+ --tags WORKING_DIRECTORY "${PROJECT_TOP}" OUTPUT_VARIABLE GIT_REV ERROR_QUIET) -if (NOT "${GIT_REV}" STREQUAL "") - execute_process( - COMMAND bash -c "git diff --quiet --exit-code && git diff --cached --quiet --exit-code || echo +" - WORKING_DIRECTORY "${PROJECT_TOP}" - OUTPUT_VARIABLE GIT_DIFF) -else() +if ("${GIT_REV}" STREQUAL "") if (EXISTS ${PROJECT_TOP}/VERSION) file(READ ${PROJECT_TOP}/VERSION GIT_REV) else() set(GIT_REV "UNKNOWN") - set(GIT_DIFF "") endif() endif() -string(STRIP "${GIT_REV}" GIT_REV) -string(STRIP "${GIT_DIFF}" GIT_DIFF) -set(GIT_VERSION "${GIT_REV}${GIT_DIFF}") +string(STRIP "${GIT_REV}" GIT_VERSION) set(BUILD_VERSION "const char * BUILD_VERSION = \"${GIT_VERSION}\";") if(EXISTS "${CMAKE_BINARY_DIR}/version.c")