2015-01-29 00:03:41 +00:00
|
|
|
# Git utilities
|
|
|
|
|
|
|
|
if(__GitUtilities)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(__GitUtilities ON)
|
|
|
|
|
|
|
|
function(git_describe variable path)
|
|
|
|
execute_process(COMMAND "${GIT_EXECUTABLE}" "describe"
|
|
|
|
WORKING_DIRECTORY "${path}"
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
OUTPUT_VARIABLE output
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
|
|
|
set(${variable} "${output}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
2015-03-05 02:15:57 +00:00
|
|
|
|
|
|
|
function(git_current_branch variable path)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} "symbolic-ref" "--short" "HEAD"
|
|
|
|
WORKING_DIRECTORY "${path}"
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
OUTPUT_VARIABLE output
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
2018-12-03 20:42:37 +00:00
|
|
|
set(${variable} "${output}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(git_latest_commit variable path)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
|
|
|
|
WORKING_DIRECTORY "${path}"
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
OUTPUT_VARIABLE output
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
2015-03-05 02:15:57 +00:00
|
|
|
set(${variable} "${output}" PARENT_SCOPE)
|
|
|
|
endfunction()
|