File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 1- version : 10.1.14
1+ version : 10.1.15
Original file line number Diff line number Diff line change 22
33exit_trap () {
44 local lc=" $BASH_COMMAND " rc=$?
5- if [ $rc ! = 0 ]; then
6- echo " Command [ $lc ] exited with code [ $rc ] "
5+ if [ " $rc " = 0 ]; then
6+ return
77 fi
8+ if [ " $CLEAN_GIT_LOCK_FILES " = " true" ] && [ " $IS_RETRY " != " true" ]; then
9+ retry_script
10+ exit $?
11+ fi
12+ echo " Command [$lc ] exited with code [$rc ]"
13+ }
14+
15+ retry_script () {
16+ echo " Retrying git clone operation..."
17+ cd ../
18+ rm -rf $CLONE_DIR
19+ export IS_RETRY=true
20+ ./$0 $@
821}
922
1023git_retry () {
@@ -31,10 +44,24 @@ git_retry () {
3144 )
3245}
3346
47+ upsert_remote_alias () {
48+ remoteAlias=$1
49+ remoteUrl=$2
50+ isOriginAliasExisted=$( git remote -v | awk ' $1 ~ /^' $remoteAlias ' $/{print $1; exit}' )
51+ if [ " $isOriginAliasExisted " = " $remoteAlias " ]; then
52+ git remote set-url $remoteAlias $remoteUrl
53+ else
54+ git remote add $remoteAlias $remoteUrl
55+ fi
56+ }
57+
58+ delete_process_lock_files () {
59+ find ./.git -type f -iname ' *.lock' -delete
60+ }
61+
3462trap exit_trap EXIT
3563set -e
3664
37-
3865[ -z " $REVISION " ] && (echo " missing REVISION var" | tee /dev/stderr) && exit 1
3966
4067
@@ -107,8 +134,11 @@ if [ -d "$CLONE_DIR" ]; then
107134
108135 # Make sure the CLONE_DIR folder is a git folder
109136 if git status & > /dev/null ; then
137+ if [ " $CLEAN_GIT_LOCK_FILES " = " true" ]; then
138+ delete_process_lock_files
139+ fi
110140 # Reset the remote URL because the embedded user token may have changed
111- git remote set-url origin $REPO
141+ upsert_remote_alias origin $REPO
112142
113143 echo " Cleaning up the working directory"
114144 git reset -q --hard
You can’t perform that action at this time.
0 commit comments