Skip to content

Commit 4c7e8fc

Browse files
support Git Clone depth with different branches (#55)
1 parent b0d1552 commit 4c7e8fc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 10.1.19
1+
version: 10.1.20

start.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ git_retry () {
2525
(
2626
set +e
2727
RETRY_ON_SIGNAL=128
28-
COMMAND=$@
28+
COMMAND=("$@") # Store the command and arguments as an array
2929
local TRY_NUM=1 MAX_TRIES=4 RETRY_WAIT=5
3030
until [[ "$TRY_NUM" -ge "$MAX_TRIES" ]]; do
31-
$COMMAND
31+
"${COMMAND[@]}" # Use "${COMMAND[@]}" to preserve arguments with quotes
3232
EXIT_CODE=$?
3333
if [[ $EXIT_CODE == 0 ]]; then
3434
break
@@ -196,6 +196,10 @@ if [ -d "$CLONE_DIR" ]; then
196196
cd $CLONE_DIR
197197

198198
if [ -n "$REVISION" ]; then
199+
if [ -n "$DEPTH" ]; then
200+
git_retry git remote set-branches origin "*"
201+
git_retry git fetch --depth=$DEPTH
202+
fi
199203
git_checkout
200204
fi
201205
fi
@@ -205,6 +209,10 @@ else
205209
eval $GIT_COMMAND
206210
cd $CLONE_DIR
207211
if [ -n "$REVISION" ]; then
212+
if [ -n "$DEPTH" ]; then
213+
git_retry git remote set-branches origin "*"
214+
git_retry git fetch --depth=$DEPTH
215+
fi
208216
git_checkout
209217
fi
210218

0 commit comments

Comments
 (0)