Skip to content

Commit b232e9f

Browse files
authored
Improvements for AZDO_BRANCH scenario (#31)
* Add a wait for ADO helper extension install before checkout * Check if branch has already been switched
1 parent b8770bb commit b232e9f

3 files changed

Lines changed: 23 additions & 2 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.0",
4+
"version": "3.0.1",
55
"description": "Configures Codespace to work with an external Git repository",
66
"options": {
77
"gitProvider": {

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,28 @@ checkout_branch() {
1111
if [[ "${AZDO_BRANCH}" == "" ]]; then
1212
return
1313
fi
14-
echo "Checking out branch ${AZDO_BRANCH}"
1514
cd ${1}
15+
16+
# Get the current branch name
17+
CURRENT_BRANCH=$(git branch --show-current)
18+
if [[ "${CURRENT_BRANCH}" == "${AZDO_BRANCH}" ]]; then
19+
echo "Already on branch ${AZDO_BRANCH}"
20+
return
21+
fi
22+
23+
echo "Checking out branch ${AZDO_BRANCH}"
24+
25+
if [ ! -f ${HOME}/ado-auth-helper ]; then
26+
echo "Waiting up to 180 seconds for ado-auth-helper extension to be installed"
27+
fi
28+
# Wait up to 3 minutes for the ado-auth-helper to be installed
29+
for i in {1..180}; do
30+
if [ -f ${HOME}/ado-auth-helper ]; then
31+
break
32+
fi
33+
sleep 1
34+
done
35+
1636
# fetch the branch named AZDO_BRANCH
1737
git fetch origin ${AZDO_BRANCH}
1838
git checkout ${AZDO_BRANCH}

test/external-repository/branch-install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -e
66
source dev-container-features-test-lib
77

88
# Definition specific tests
9+
touch ${HOME}/ado-auth-helper
910
check "git-config" grep "ado-auth-helper" <(cat /tmp/branch-repos/.git/config)
1011
check "branch" grep "joshaber/parallel-execution-schema" <(git -C /tmp/branch-repos branch --show-current)
1112

0 commit comments

Comments
 (0)