Skip to content

Commit 142ab2f

Browse files
authored
Fix CMake version info bad quoting (#501)
* Fix quote escaping in commit message * This is a "Test message" * Update to latest cmake-git-version-tracking git_watcher cmake file Listed permalink to make it easier to diff any future changes
1 parent 2eaf52c commit 142ab2f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmake/git_watcher.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# git_watcher.cmake
2-
# https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/git_watcher.cmake
2+
# https://github.com/andrew-hardin/cmake-git-version-tracking/blob/20c58d5d08bad70550d969b478943c962faa6264/git_watcher.cmake
33
#
44
# Released under the MIT License.
55
# https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/LICENSE
@@ -158,13 +158,16 @@ function(GetGitState _working_dir)
158158

159159
RunGitCommand(show -s "--format=%s" ${object})
160160
if(exit_code EQUAL 0)
161+
# Escape quotes
161162
string(REPLACE "\"" "\\\"" output "${output}")
162163
set(ENV{GIT_COMMIT_SUBJECT} "${output}")
163164
endif()
164165

165166
RunGitCommand(show -s "--format=%b" ${object})
166167
if(exit_code EQUAL 0)
167168
if(output)
169+
# Escape quotes
170+
string(REPLACE "\"" "\\\"" output "${output}")
168171
# Escape line breaks in the commit message.
169172
string(REPLACE "\r\n" "\\r\\n\\\r\n" safe "${output}")
170173
if(safe STREQUAL output)
@@ -180,6 +183,14 @@ function(GetGitState _working_dir)
180183
set(ENV{GIT_COMMIT_BODY} "\"\"") # empty string.
181184
endif()
182185

186+
# Get output of git describe
187+
RunGitCommand(describe --always ${object})
188+
if(NOT exit_code EQUAL 0)
189+
set(ENV{GIT_DESCRIBE} "unknown")
190+
else()
191+
set(ENV{GIT_DESCRIBE} "${output}")
192+
endif()
193+
183194
# >>>
184195
# 2. Additional git properties can be added here via the
185196
# "execute_process()" command. Be sure to set them in

0 commit comments

Comments
 (0)