From ee2d1f677b3b8488180746951f1c4db681f60e64 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 13 Jan 2022 16:29:42 -0800 Subject: [PATCH] CMake: Clean up ref names in git branch string (fixes #2421) --- version.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/version.cmake b/version.cmake index b40c9d47b..0c79562cd 100644 --- a/version.cmake +++ b/version.cmake @@ -15,6 +15,8 @@ if(GIT AND NOT SKIP_GIT) execute_process(COMMAND ${GIT} symbolic-ref --short HEAD WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT} rev-list HEAD --count WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_REV ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT} describe --tag --exact-match WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_TAG ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REGEX REPLACE "^(refs/)?(heads|tags)/" "" GIT_BRANCH "${GIT_BRANCH}") endif() if(NOT GIT_REV)