From b8896742f80cae0d7f41519132e3186c7088331c Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Mon, 27 Sep 2021 01:03:56 -0400 Subject: [PATCH 1/2] Fix `GIT_DESCRIBE` generation Initially attempt to find tags excluding "Audacity-" and "DarkAudacity-" Allow graceful fallback case for "Audacity-" tags Add logic to remove "DarkAudacity-" tag prefix to match "Audacity-" tag behavior Signed-off-by: Emily Mabrey --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ea797684..b04e2deca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,19 +68,31 @@ set( TENACITY_MODLEVEL 0 ) # Additional version detail set( GIT_DESCRIBE "unknown" ) if( GIT_FOUND ) + # Attempt to first get "Tenacity-" tags execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 + COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 --exclude="Audacity-*" --exclude="DarkAudacity-*" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) - if( GIT_DESCRIBE ) + if( DEFINED GIT_DESCRIBE AND GIT_DESCRIBE STREQUAL "" ) + # Retry, this time accepting "Audacity-" tags + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=7 --exclude="DarkAudacity-*" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET + ) + endif() + + if( DEFINED GIT_DESCRIBE AND NOT GIT_DESCRIBE STREQUAL "" ) + # Copy to new variable for string manipulation set( git_output ${GIT_DESCRIBE} ) - # TODO: Remove this after first Tenacity release string( REPLACE "Audacity-" "" git_output "${git_output}" ) + string( REPLACE "DarkAudacity-" "" git_output "${git_output}" ) string( REGEX REPLACE "-.*" "" git_output "${git_output}" ) string( REPLACE "." ";" git_output "${git_output}" ) From 13b2273a893d7e948d8a182dc122def38f74e0b5 Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Mon, 27 Sep 2021 01:19:24 -0400 Subject: [PATCH 2/2] Add Git describe validation Validate the output CMake list for `git_output` is the right length Signed-off-by: Emily Mabrey --- CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b04e2deca..de2568eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,13 @@ if( GIT_FOUND ) string( REGEX REPLACE "-.*" "" git_output "${git_output}" ) string( REPLACE "." ";" git_output "${git_output}" ) - list( GET git_output 0 AUDACITY_VERSION ) - list( GET git_output 1 AUDACITY_RELEASE ) - list( GET git_output 2 AUDACITY_REVISION ) + list( LENGTH git_output GIT_OUTPUT_LIST_LENGTH ) + + if( GIT_OUTPUT_LIST_LENGTH GREATER_EQUAL 3 ) + list( GET git_output 0 AUDACITY_VERSION ) + list( GET git_output 1 AUDACITY_RELEASE ) + list( GET git_output 2 AUDACITY_REVISION ) + endif() endif() endif()