Bugfixes für install.sh: 1) Zustandsvariable statt Exit-Code für Updates, 2) Stash-Mechanismus für git checkout mit lokalen Änderungen
This commit is contained in:
+33
-4
@@ -11,6 +11,7 @@ ARG_LANG=""
|
||||
NONINTERACTIVE=false
|
||||
CHECK_ONLY=false
|
||||
UPDATE_MODE=false
|
||||
UPDATE_AVAILABLE=false
|
||||
|
||||
# ─── Language packs ─────────────────────────────────────────
|
||||
declare -A T
|
||||
@@ -160,15 +161,18 @@ check_for_updates() {
|
||||
# If we can't determine versions, exit with error
|
||||
if [ "$local_version" = "unknown" ] || [ "$remote_version" = "unknown" ]; then
|
||||
echo "Could not determine version information"
|
||||
return 1
|
||||
UPDATE_AVAILABLE=false
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Compare versions
|
||||
if [ "$local_version" != "$remote_version" ]; then
|
||||
msg update_available "$remote_version" "$local_version"
|
||||
return 1 # Update available
|
||||
UPDATE_AVAILABLE=true
|
||||
return 0 # Update available
|
||||
else
|
||||
msg no_update "$local_version"
|
||||
UPDATE_AVAILABLE=false
|
||||
return 0 # No update needed
|
||||
fi
|
||||
}
|
||||
@@ -195,12 +199,23 @@ perform_update() {
|
||||
# Change to repo directory
|
||||
cd "$script_dir"
|
||||
|
||||
# Check if we have local changes and stash if needed
|
||||
local stashed=false
|
||||
if ! git diff --quiet; then
|
||||
git stash push -m "Auto-stash before update"
|
||||
stashed=true
|
||||
fi
|
||||
|
||||
# Get remote version
|
||||
local remote_version
|
||||
remote_version=$(git ls-remote --tags origin | grep -E 'refs/tags/v[0-9]+(\.[0-9]+)*$' | sed 's|.*refs/tags/||' | sort -V | tail -n1 || echo "unknown")
|
||||
|
||||
if [ "$remote_version" = "unknown" ]; then
|
||||
msg update_failed "Could not determine remote version"
|
||||
# Restore stash if we had changes
|
||||
if $stashed; then
|
||||
git stash pop 2>/dev/null || true
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -247,6 +262,11 @@ perform_update() {
|
||||
rm -f "$backup_file"
|
||||
fi
|
||||
|
||||
# Restore stash if we had changes
|
||||
if $stashed; then
|
||||
git stash pop 2>/dev/null || true
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -255,6 +275,11 @@ perform_update() {
|
||||
|
||||
msg update_success "$remote_version"
|
||||
|
||||
# Restore stash if we had changes
|
||||
if $stashed; then
|
||||
git stash pop 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Restart gateway
|
||||
if [ -n "$hermes_dir" ]; then
|
||||
cd "$hermes_dir"
|
||||
@@ -295,10 +320,14 @@ echo -e "\n${T[banner]}\n"
|
||||
# ─── Update Check/Perform ──────────────────────────────────────
|
||||
if $CHECK_ONLY; then
|
||||
check_for_updates
|
||||
exit $?
|
||||
if $UPDATE_AVAILABLE; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
elif $UPDATE_MODE; then
|
||||
check_for_updates
|
||||
if [ $? -eq 1 ]; then
|
||||
if $UPDATE_AVAILABLE; then
|
||||
perform_update
|
||||
exit $?
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user