Skip to content

Commit

Permalink
fix issue microsoft#9228 : Add support to subgroups in gitlab (micros…
Browse files Browse the repository at this point in the history
…oft#9248)

* fix issue microsoft#9228 : Add support to subgroups in gitlab

* Update vcpkg_from_gitlab.cmake

* Update vcpkg_from_gitlab.cmake
  • Loading branch information
RamadanAhmed authored and hellozee committed Sep 11, 2020
1 parent 8009092 commit b7e6ff1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions scripts/cmake/vcpkg_from_gitlab.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,22 @@ function(vcpkg_from_gitlab)
set(VCPKG_USE_HEAD_VERSION OFF)
endif()

string(REGEX REPLACE ".*/" "" REPO_NAME ${_vdud_REPO})
string(REGEX REPLACE "/.*" "" ORG_NAME ${_vdud_REPO})

string(REPLACE "/" ";" GITLAB_REPO_LINK ${_vdud_REPO})

list(LENGTH GITLAB_REPO_LINK len)
if(${len} EQUAL "2")
list(GET GITLAB_REPO_LINK 0 ORG_NAME)
list(GET GITLAB_REPO_LINK 1 REPO_NAME)
set(GITLAB_LINK ${_vdud_GITLAB_URL}/${ORG_NAME}/${REPO_NAME})
endif()

if(${len} EQUAL "3")
list(GET GITLAB_REPO_LINK 0 ORG_NAME)
list(GET GITLAB_REPO_LINK 1 GROUP_NAME)
list(GET GITLAB_REPO_LINK 2 REPO_NAME)
set(GITLAB_LINK ${_vdud_GITLAB_URL}/${ORG_NAME}/${GROUP_NAME}/${REPO_NAME})
endif()

# Handle --no-head scenarios
if(NOT VCPKG_USE_HEAD_VERSION)
if(NOT _vdud_REF)
Expand All @@ -103,7 +116,7 @@ function(vcpkg_from_gitlab)
string(REPLACE "/" "-" SANITIZED_REF "${_vdud_REF}")

vcpkg_download_distfile(ARCHIVE
URLS "${_vdud_GITLAB_URL}/${ORG_NAME}/${REPO_NAME}/-/archive/${_vdud_REF}/${REPO_NAME}-${_vdud_REF}.tar.gz"
URLS "${GITLAB_LINK}/-/archive/${_vdud_REF}/${REPO_NAME}-${_vdud_REF}.tar.gz"
SHA512 "${_vdud_SHA512}"
FILENAME "${ORG_NAME}-${REPO_NAME}-${SANITIZED_REF}.tar.gz"
)
Expand All @@ -120,7 +133,7 @@ function(vcpkg_from_gitlab)
endif()

# The following is for --head scenarios
set(URL "${_vdud_GITLAB_URL}/${ORG_NAME}/${REPO_NAME}/-/archive/${_vdud_HEAD_REF}/${_vdud_HEAD_REF}.tar.gz")
set(URL "${GITLAB_LINK}/-/archive/${_vdud_HEAD_REF}/${_vdud_HEAD_REF}.tar.gz")
string(REPLACE "/" "-" SANITIZED_HEAD_REF "${_vdud_HEAD_REF}")
set(downloaded_file_name "${ORG_NAME}-${REPO_NAME}-${SANITIZED_HEAD_REF}.tar.gz")
set(downloaded_file_path "${DOWNLOADS}/${downloaded_file_name}")
Expand Down Expand Up @@ -151,7 +164,7 @@ function(vcpkg_from_gitlab)

# There are issues with the Gitlab API project paths being URL-escaped, so we use git here to get the head revision
_execute_process(COMMAND ${GIT} ls-remote
"${_vdud_GITLAB_URL}/${ORG_NAME}/${REPO_NAME}.git" "${_vdud_HEAD_REF}"
"${GITLAB_LINK}.git" "${_vdud_HEAD_REF}"
RESULT_VARIABLE _git_result
OUTPUT_VARIABLE _git_output
)
Expand Down

0 comments on commit b7e6ff1

Please sign in to comment.