2
2
3
3
exit_trap () {
4
4
local lc=" $BASH_COMMAND " rc=$?
5
- echo " Exit trap triggered with command: [$lc ] and exit code [$rc ]"
6
5
if [ " $rc " = 0 ]; then
7
6
return
8
7
fi
9
8
if [ " $CLEAN_GIT_LOCK_FILES " = " true" ] && [ " $IS_RETRY " != " true" ]; then
10
- echo " Cleaning git lock files and retrying the script..."
11
9
retry_script
12
10
exit $?
13
11
fi
@@ -19,13 +17,11 @@ retry_script () {
19
17
cd ../
20
18
rm -rf $CLONE_DIR
21
19
export IS_RETRY=true
22
- echo " Re-executing script with arguments: $@ "
23
- $0 " $@ "
20
+ $0 $@
24
21
}
25
22
26
23
git_retry () {
27
24
# Retry git on exit code 128
28
- echo " Executing git command with retry logic: $@ "
29
25
(
30
26
set +e
31
27
RETRY_ON_SIGNAL=128
@@ -34,31 +30,18 @@ echo "Executing git command with retry logic: $@"
34
30
until [[ " $TRY_NUM " -ge " $MAX_TRIES " ]]; do
35
31
" ${COMMAND[@]} " # Use "${COMMAND[@]}" to preserve arguments with quotes
36
32
EXIT_CODE=$?
37
-
38
- # Log the command output and error messages
39
- echo " Command output (stdout):"
40
- cat " $OUTPUT_LOG "
41
- echo " Command error (stderr):"
42
- cat " $ERROR_LOG "
43
-
44
33
if [[ $EXIT_CODE == 0 ]]; then
45
- echo " Command succeeded on attempt $TRY_NUM ."
46
34
break
47
35
elif [[ $EXIT_CODE == " $RETRY_ON_SIGNAL " ]]; then
48
36
echo " Failed with Exit Code $EXIT_CODE - try $TRY_NUM "
49
37
TRY_NUM=$(( ${TRY_NUM} + 1 ))
50
38
sleep $RETRY_WAIT
51
39
else
52
- echo " Command failed with exit code $EXIT_CODE . No retry configured for this code."
53
- echo " Failed command: ${COMMAND[*]} "
54
- echo " Exit Code: $EXIT_CODE "
55
- echo " Output Log: $OUTPUT_LOG "
56
- echo " Error Log: $ERROR_LOG "
57
40
break
58
41
fi
59
- done
60
- return $EXIT_CODE
61
- )
42
+ done
43
+ return $EXIT_CODE
44
+ )
62
45
}
63
46
64
47
upsert_remote_alias () {
@@ -220,9 +203,8 @@ if [ -d "$CLONE_DIR" ]; then
220
203
echo " Fetching updates from origin${DEPTH: + with depth $DEPTH } , skipping tags"
221
204
git_retry git fetch origin ${REVISION: +$REVISION } --no-tags ${DEPTH: + --depth=$DEPTH }
222
205
else
223
- echo " Fetching updates from origin"
224
- git_retry git fetch origin --tags --prune " +refs/tags/*:refs/tags/*" ${DEPTH: + --depth=$DEPTH }
225
- echo " DONE Fetching updates from origin"
206
+ echo " Fetching updates from origin${DEPTH: + with depth $DEPTH } "
207
+ git_retry git fetch origin ${REVISION: +$REVISION } --tags --prune " +refs/tags/*:refs/tags/*" ${DEPTH: + --depth=$DEPTH }
226
208
fi
227
209
228
210
git remote set-head origin --auto
0 commit comments