Skip to content

Commit c40bce5

Browse files
authored
Fix bug when multi-repos clone includes a repo name containing a . (#37)
Added more tests to cover this scenario
1 parent 2079962 commit c40bce5

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/external-repository/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "External Git Repository in Codespace",
33
"id": "external-repository",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"description": "Configures Codespace to work with an external Git repository",
66
"options": {
77
"gitProvider": {

src/external-repository/scripts/clone.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ if [ ${#EXT_GIT_REPO_URL_ARRAY[@]} -gt 1 ]; then
131131
for i in "${EXT_GIT_REPO_URL_ARRAY[@]}"; do
132132
# Set the repo URL to the current value
133133
REPO_URL=$i
134-
# Get the folder name from the last part of the URL
135-
REPO_FOLDER=$(echo "${REPO_URL}" | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}')
134+
# Get the folder name from the last part of the URL (dropping .git if necessary)
135+
REPO_FOLDER=$(echo "${REPO_URL}" | sed 's/\.git$//;s#.*/##')
136136
LOCAL_PATH=${EXT_GIT_LOCAL_PATH}/${REPO_FOLDER}
137137
# Clone the repo
138138
clone_repository ${REPO_URL} ${LOCAL_PATH}

src/external-repository/scripts/setup-user.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ if [ ${#EXT_GIT_REPO_URL_ARRAY[@]} -gt 1 ]; then
176176
for i in "${EXT_GIT_REPO_URL_ARRAY[@]}"; do
177177
# Set the repo URL to the current value
178178
REPO_URL=$i
179-
# Get the folder name from the last part of the URL
180-
REPO_FOLDER=$(echo "${REPO_URL}" | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}')
179+
# Get the folder name from the last part of the URL (dropping .git if necessary)
180+
REPO_FOLDER=$(echo "${REPO_URL}" | sed 's/\.git$//;s#.*/##')
181181
LOCAL_PATH=${EXT_GIT_LOCAL_PATH}/${REPO_FOLDER}
182182
# Clone the repo
183183
configure_git_for_user ${LOCAL_PATH}

test/external-repository/multi-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source dev-container-features-test-lib
88
# Definition specific tests
99
check "git-config-1" grep "ado-auth-helper" <(cat /tmp/multi-repos/community/.git/config)
1010
check "git-config-2" grep "ado-auth-helper" <(cat /tmp/multi-repos/spec/.git/config)
11-
check "git-config-3" grep "ado-auth-helper" <(cat /tmp/multi-repos/action/.git/config)
11+
check "git-config-3" grep "ado-auth-helper" <(cat /tmp/multi-repos/devcontainers.github.io/.git/config)
1212

1313
# Report result
1414
reportResults

test/external-repository/scenarios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
1414
"features": {
1515
"external-repository": {
16-
"cloneUrl": "https://github.com/devcontainers/community,https://github.com/devcontainers/spec,https://github.com/devcontainers/action",
16+
"cloneUrl": "https://github.com/devcontainers/community,https://github.com/devcontainers/spec.git,https://github.com/devcontainers/devcontainers.github.io",
1717
"folder": "/tmp/multi-repos"
1818
}
1919
},

0 commit comments

Comments
 (0)