Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove .git extension when checking for remote existence #282

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
# install vcpkg dependencies: - should be called before defining project()
run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
)
# Install conan dependencies: - should be called before defining project()
run_conan()
Expand Down
2 changes: 1 addition & 1 deletion docs/src/project_options_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
# install vcpkg dependencies: - should be called before defining project()
run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
)
# Install conan dependencies: - should be called before defining project()
run_conan()
Expand Down
15 changes: 7 additions & 8 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 All @@ -343,12 +346,8 @@ function(git_add_remote)
endif()

execute_process(
COMMAND "${GIT_EXECUTABLE}" "remote" "add" "${_fun_REMOTE_NAME}" "${_fun_REMOTE_URL}"
WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}" COMMAND_ERROR_IS_FATAL LAST
)
execute_process(
COMMAND "${GIT_EXECUTABLE}" "fetch" "${_fun_REMOTE_NAME}" WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
COMMAND_ERROR_IS_FATAL LAST
COMMAND "${GIT_EXECUTABLE}" "remote" "add" "--fetch" "${_fun_REMOTE_NAME}" "${_fun_REMOTE_URL}"
WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
)
endif()
endfunction()
Expand Down
2 changes: 1 addition & 1 deletion src/Vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Or by specifying the options

run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
ENABLE_VCPKG_UPDATE
)

Expand Down
2 changes: 1 addition & 1 deletion tests/install/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "another-project",
"version-string": "0.1.0",
"builtin-baseline": "10e052511428d6b0c7fcc63a139e8024bb146032",
"builtin-baseline": "86a181505ac6460f98496a79abdee6a0f49905ec",
"dependencies": [
{
"name": "eigen3",
Expand Down
2 changes: 1 addition & 1 deletion tests/myproj/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(ENABLE_CROSS_COMPILING)
endif()

run_vcpkg(VCPKG_URL "https://github.com/microsoft/vcpkg.git" VCPKG_REV
"10e052511428d6b0c7fcc63a139e8024bb146032" ENABLE_VCPKG_UPDATE
"86a181505ac6460f98496a79abdee6a0f49905ec" ENABLE_VCPKG_UPDATE
)
run_conan()

Expand Down
2 changes: 1 addition & 1 deletion tests/myproj/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "myproject",
"version-string": "0.1.0",
"builtin-baseline": "10e052511428d6b0c7fcc63a139e8024bb146032",
"builtin-baseline": "86a181505ac6460f98496a79abdee6a0f49905ec",
"dependencies": [
{
"name": "eigen3",
Expand Down
Loading