Skip to content

Commit

Permalink
Remove quotes from --pretty argument value (TriBITSPub#483)
Browse files Browse the repository at this point in the history
In this case, there are no spaces in the --pretty=format:<value> argument so
we don't need the quotes and therefore don't need to suffer the complexity of
removing them after the fact.

But note the case I copied and pasted this from in
tribits_generate_single_repo_version_string() still requires them because that
format spec has spaces.
  • Loading branch information
bartlettroscoe committed Jun 10, 2022
1 parent 165afca commit 8851da6
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,17 @@ function(tribits_git_repo_sha1 gitRepoDir gitRepoSha1Out)
set(gitRepoSha1 "")
if (failureMsg STREQUAL "")
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%H"
COMMAND ${GIT_EXECUTABLE} log -1 "--pretty=format:%H"
WORKING_DIRECTORY ${gitRepoDir}
RESULT_VARIABLE gitCmndRtn OUTPUT_VARIABLE gitCmndOutput
)
# NOTE: Above we have to add quotes '"' or CMake will not accept the
# command. However, git will put those quotes in the output so we have to
# strip them out below!

if (NOT gitCmndRtn STREQUAL 0)
set(failureMsg "ERROR: ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0 for repo ${gitRepoDir}!")
else()
# Strip the quotes off :-(
string(LENGTH "${gitCmndOutput}" gitCmndOutputLen)
math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2")
string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} gitRepoSha1)
set(gitRepoSha1 "${gitCmndOutput}")
endif()
endif()
# ToDo: Factor above out into its own function!

if (NOT failureMsg STREQUAL "" AND PARSE_FAILURE_MESSAGE_OUT STREQUAL "")
message(FATAL_ERROR "${failureMsg}")
Expand Down

0 comments on commit 8851da6

Please sign in to comment.