Skip to content

Commit

Permalink
fix: remove .git extension when checking for remote existence
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 2, 2024
1 parent ca3ecdc commit 02346e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Git.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 02346e2

Please sign in to comment.