Skip to content

Commit

Permalink
fix infinite loop if error during pull by aborting autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
joe128 committed Jan 9, 2022
1 parent ff29934 commit eb793a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [3.1.1] - 2022-01-09
### Fixed
- abort if there were an error during pull of new commits, to prevent an infinite loop

## [3.1.0] - 2022-01-08
### Added
- show branch-tip after update
Expand Down
14 changes: 8 additions & 6 deletions anyScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ if [ -n "${gitbin}" ] && [ ! -f "$(dirname "$0")/.autoUpdateDisable" ] && [ -z "
echo "[autoUpdate] Found updates ($commits commits)..."
[ $doHardReset -gt 0 ] && $gitbin reset --hard
$gitbin pull --force
localTip=$(${gitbin} show --abbrev-commit --format=oneline $(${gitbin} rev-list --max-count=1 @{u}) | head -1)
echo "[autoUpdate] source is now at commit '$localTip'"
if [ ! $? ]; then
localTip=$(${gitbin} show --abbrev-commit --format=oneline $(${gitbin} rev-list --max-count=1 @{u}) | head -1)
echo "[autoUpdate] source is now at commit '$localTip'"

echo "[autoUpdate] Executing new version..."
exec "$(pwd -P)/${scriptName}" "$@"
# In case executing new fails
echo "[ERR][autoUpdate] Executing new version failed."
echo "[autoUpdate] Executing new version..."
exec "$(pwd -P)/${scriptName}" "$@"
fi
# In case there were an error (during pull or executing new)
echo "[ERR][autoUpdate] Pulling or executing new version failed."
exit 1
fi
echo "[autoUpdate] No updates available."
Expand Down

0 comments on commit eb793a6

Please sign in to comment.