Skip to content

Commit 02346e2

Browse files
committed
fix: remove .git extension when checking for remote existence
1 parent ca3ecdc commit 02346e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Git.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,16 @@ function(git_add_remote)
319319

320320
find_program(GIT_EXECUTABLE "git" REQUIRED)
321321

322-
# ensure that the given repository's remote is the current remote
322+
# Get the list of the remotes
323323
execute_process(
324324
COMMAND "${GIT_EXECUTABLE}" "remote" "-v" WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
325325
COMMAND_ERROR_IS_FATAL LAST
326326
OUTPUT_VARIABLE _remote_output
327327
)
328-
string(FIND "${_remote_output}" "${_fun_REMOTE_URL}" _find_index)
328+
# Remove .git from the URL
329+
string(REGEX REPLACE "^(.*)\.git$" "\\1" _fun_REMOTE_URL_no_git "${_fun_REMOTE_URL}")
330+
# Check if the given remote already exists in the remote list
331+
string(FIND "${_remote_output}" "${_fun_REMOTE_URL_no_git}" _find_index)
329332

330333
# Add the given remote if it doesn't exist
331334
if(${_find_index} EQUAL -1)

0 commit comments

Comments
 (0)