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 2
2
3
3
exit_trap () {
4
4
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
7
7
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 $@
8
21
}
9
22
10
23
git_retry () {
@@ -31,10 +44,24 @@ git_retry () {
31
44
)
32
45
}
33
46
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
+
34
62
trap exit_trap EXIT
35
63
set -e
36
64
37
-
38
65
[ -z " $REVISION " ] && (echo " missing REVISION var" | tee /dev/stderr) && exit 1
39
66
40
67
@@ -107,8 +134,11 @@ if [ -d "$CLONE_DIR" ]; then
107
134
108
135
# Make sure the CLONE_DIR folder is a git folder
109
136
if git status & > /dev/null ; then
137
+ if [ " $CLEAN_GIT_LOCK_FILES " = " true" ]; then
138
+ delete_process_lock_files
139
+ fi
110
140
# 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
112
142
113
143
echo " Cleaning up the working directory"
114
144
git reset -q --hard
You can’t perform that action at this time.
0 commit comments