Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 10.1.14
version: 10.1.15
38 changes: 34 additions & 4 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

exit_trap () {
local lc="$BASH_COMMAND" rc=$?
if [ $rc != 0 ]; then
echo "Command [$lc] exited with code [$rc]"
if [ "$rc" = 0 ]; then
return
fi
if [ "$CLEAN_GIT_LOCK_FILES" = "true" ] && [ "$IS_RETRY" != "true" ]; then
retry_script
exit $?
fi
echo "Command [$lc] exited with code [$rc]"
}

retry_script () {
echo "Retrying git clone operation..."
cd ../
rm -rf $CLONE_DIR
export IS_RETRY=true
./$0 $@
}

git_retry () {
Expand All @@ -31,10 +44,24 @@ git_retry () {
)
}

upsert_remote_alias () {
remoteAlias=$1
remoteUrl=$2
isOriginAliasExisted=$(git remote -v | awk '$1 ~ /^'$remoteAlias'$/{print $1; exit}')
if [ "$isOriginAliasExisted" = "$remoteAlias" ]; then
git remote set-url $remoteAlias $remoteUrl
else
git remote add $remoteAlias $remoteUrl
fi
}

delete_process_lock_files () {
find ./.git -type f -iname '*.lock' -delete
}

trap exit_trap EXIT
set -e


[ -z "$REVISION" ] && (echo "missing REVISION var" | tee /dev/stderr) && exit 1


Expand Down Expand Up @@ -107,8 +134,11 @@ if [ -d "$CLONE_DIR" ]; then

# Make sure the CLONE_DIR folder is a git folder
if git status &> /dev/null ; then
if [ "$CLEAN_GIT_LOCK_FILES" = "true" ]; then
delete_process_lock_files
fi
# Reset the remote URL because the embedded user token may have changed
git remote set-url origin $REPO
upsert_remote_alias origin $REPO

echo "Cleaning up the working directory"
git reset -q --hard
Expand Down