Skip to content

Commit

Permalink
[mk] Fix adr checkout. (#21835)
Browse files Browse the repository at this point in the history
* Fix local checkout to only pass the extra http header if we have a SYSTEM_ACCESSTOKEN.
* Use a bash array to store authorization arguments, because quoting each
  argument actually works when expanding an array into arguments - in
  particular expanding an empty array expands into nothing (this avoids a
  problem where DEPENDENCY_AUTH would be expanded into an empty (and quoted)
  string, which would execute doing 'git ""', and "" is not a git command.)
* Fix clone command to not forget the 'clone' part of 'git clone ...'
  • Loading branch information
rolfbjarne authored Dec 20, 2024
1 parent 2943ab0 commit 874ee22
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mk/xamarin-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if test -n "$V"; then set -x; fi
DEPENDENCY_NAME="$1"

# Calculate the remote from the format: [email protected]:<remote>/<repo>.git
DEPENDENCY_AUTH=()
if [[ $DEPENDENCY_MODULE =~ [email protected] ]]; then
# git@ url
DEPENDENCY_REMOTE=${DEPENDENCY_MODULE/git@github.com:/}
Expand All @@ -16,10 +17,13 @@ elif [[ $DEPENDENCY_MODULE =~ https://github.com ]]; then
elif [[ $DEPENDENCY_MODULE =~ [email protected] ]]; then
DEPENDENCY_REMOTE=${DEPENDENCY_MODULE/https:\/\/devdiv@dev.azure.com\/devdiv\/}
DEPENDENCY_REMOTE=${DEPENDENCY_REMOTE%%/_git*}
DEPENDENCY_AUTH="-c http.extraheader=\"AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN\""
if test -n "$SYSTEM_ACCESSTOKEN"; then
DEPENDENCY_AUTH+=("-c")
DEPENDENCY_AUTH+=("http.extraheader='AUTHORIZATION: bearer $SYSTEM_ACCESSTOKEN'")
fi
fi

echo "*** [$DEPENDENCY_NAME] testing fot git repo in $DEPENDENCY_PATH"
echo "*** [$DEPENDENCY_NAME] testing for git repo in $DEPENDENCY_PATH"
if test -d "$DEPENDENCY_PATH"; then
cd "$DEPENDENCY_PATH"
# Check if we have the remote we need
Expand All @@ -39,10 +43,10 @@ if test -d "$DEPENDENCY_PATH"; then
fi

else
echo "*** [$DEPENDENCY_NAME] git $DEPENDENCY_AUTH clone $DEPENDENCY_MODULE --recursive $DEPENDENCY_DIRECTORY -b $DEPENDENCY_BRANCH --origin $DEPENDENCY_REMOTE"
echo "*** [$DEPENDENCY_NAME] git ${DEPENDENCY_AUTH[*]} clone $DEPENDENCY_MODULE --recursive $DEPENDENCY_DIRECTORY -b $DEPENDENCY_BRANCH --origin $DEPENDENCY_REMOTE"
mkdir -p "$(dirname "$DEPENDENCY_PATH")"
cd "$(dirname "$DEPENDENCY_PATH")"
git "$DEPENDENCY_AUTH" "$DEPENDENCY_MODULE" --recursive "$DEPENDENCY_DIRECTORY" -b "$DEPENDENCY_BRANCH" --origin "$DEPENDENCY_REMOTE"
git "${DEPENDENCY_AUTH[@]}" clone "$DEPENDENCY_MODULE" --recursive "$DEPENDENCY_DIRECTORY" -b "$DEPENDENCY_BRANCH" --origin "$DEPENDENCY_REMOTE"
cd "$DEPENDENCY_DIRECTORY"
fi

Expand Down

10 comments on commit 874ee22

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.