Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cmake/GitCheckout.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ function(_find_git)
endif()
endfunction()

# Checks whether the given path is a directory containing a valid Git repository.
#
# Arguments:
# - PATH: The path to check.
# - OUTPUT: The output variable that will be set with a boolean indicating whether the path is a directory containing
# a valid Git repository.
function(_check_valid_git_directory PATH OUTPUT)
if(IS_DIRECTORY "${PATH}")
_find_git()
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C "${PATH}" rev-parse --is-inside-work-tree
RESULT_VARIABLE RES
)
if(RES EQUAL 0)
set("${OUTPUT}" TRUE PARENT_SCOPE)
return()
endif()
endif()

set("${OUTPUT}" FALSE PARENT_SCOPE)
endfunction()

# Gets the path of the directory to check out the Git repository.
#
# If the 'DIRECTORY' argument is empty, it will set the 'OUTPUT' argument based on the location of the remote Git
Expand Down