From 02346e20adcb6296e5df53ee9a4169886eaca9d3 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 2 Oct 2024 01:54:38 -0700 Subject: [PATCH] fix: remove .git extension when checking for remote existence --- src/Git.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Git.cmake b/src/Git.cmake index a73e12ad..a51815af 100644 --- a/src/Git.cmake +++ b/src/Git.cmake @@ -319,13 +319,16 @@ function(git_add_remote) find_program(GIT_EXECUTABLE "git" REQUIRED) - # ensure that the given repository's remote is the current remote + # Get the list of the remotes execute_process( COMMAND "${GIT_EXECUTABLE}" "remote" "-v" WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}" COMMAND_ERROR_IS_FATAL LAST OUTPUT_VARIABLE _remote_output ) - string(FIND "${_remote_output}" "${_fun_REMOTE_URL}" _find_index) + # Remove .git from the URL + string(REGEX REPLACE "^(.*)\.git$" "\\1" _fun_REMOTE_URL_no_git "${_fun_REMOTE_URL}") + # Check if the given remote already exists in the remote list + string(FIND "${_remote_output}" "${_fun_REMOTE_URL_no_git}" _find_index) # Add the given remote if it doesn't exist if(${_find_index} EQUAL -1)