Skip to content

Commit 1d82ab0

Browse files
[BE]:Fix git set url (#44)
* Fix git set url * Up version * Add final fallbacks * Refactor * Test env variable * Make test env variable * Make test env variable * Refactor * Remove not needing condition * Remove not needing new line * Refactor * Refactor
1 parent f917165 commit 1d82ab0

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

service.yaml

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

start.sh

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@
22

33
exit_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

1023
git_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+
3462
trap exit_trap EXIT
3563
set -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

0 commit comments

Comments
 (0)