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
|
NONINTERACTIVE=false
|
||||||
CHECK_ONLY=false
|
CHECK_ONLY=false
|
||||||
UPDATE_MODE=false
|
UPDATE_MODE=false
|
||||||
|
UPDATE_AVAILABLE=false
|
||||||
|
|
||||||
# ─── Language packs ─────────────────────────────────────────
|
# ─── Language packs ─────────────────────────────────────────
|
||||||
declare -A T
|
declare -A T
|
||||||
@@ -160,15 +161,18 @@ check_for_updates() {
|
|||||||
# If we can't determine versions, exit with error
|
# If we can't determine versions, exit with error
|
||||||
if [ "$local_version" = "unknown" ] || [ "$remote_version" = "unknown" ]; then
|
if [ "$local_version" = "unknown" ] || [ "$remote_version" = "unknown" ]; then
|
||||||
echo "Could not determine version information"
|
echo "Could not determine version information"
|
||||||
return 1
|
UPDATE_AVAILABLE=false
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compare versions
|
# Compare versions
|
||||||
if [ "$local_version" != "$remote_version" ]; then
|
if [ "$local_version" != "$remote_version" ]; then
|
||||||
msg update_available "$remote_version" "$local_version"
|
msg update_available "$remote_version" "$local_version"
|
||||||
return 1 # Update available
|
UPDATE_AVAILABLE=true
|
||||||
|
return 0 # Update available
|
||||||
else
|
else
|
||||||
msg no_update "$local_version"
|
msg no_update "$local_version"
|
||||||
|
UPDATE_AVAILABLE=false
|
||||||
return 0 # No update needed
|
return 0 # No update needed
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -195,12 +199,23 @@ perform_update() {
|
|||||||
# Change to repo directory
|
# Change to repo directory
|
||||||
cd "$script_dir"
|
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
|
# Get remote version
|
||||||
local 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")
|
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
|
if [ "$remote_version" = "unknown" ]; then
|
||||||
msg update_failed "Could not determine remote version"
|
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
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -247,6 +262,11 @@ perform_update() {
|
|||||||
rm -f "$backup_file"
|
rm -f "$backup_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore stash if we had changes
|
||||||
|
if $stashed; then
|
||||||
|
git stash pop 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +275,11 @@ perform_update() {
|
|||||||
|
|
||||||
msg update_success "$remote_version"
|
msg update_success "$remote_version"
|
||||||
|
|
||||||
|
# Restore stash if we had changes
|
||||||
|
if $stashed; then
|
||||||
|
git stash pop 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Restart gateway
|
# Restart gateway
|
||||||
if [ -n "$hermes_dir" ]; then
|
if [ -n "$hermes_dir" ]; then
|
||||||
cd "$hermes_dir"
|
cd "$hermes_dir"
|
||||||
@@ -295,10 +320,14 @@ echo -e "\n${T[banner]}\n"
|
|||||||
# ─── Update Check/Perform ──────────────────────────────────────
|
# ─── Update Check/Perform ──────────────────────────────────────
|
||||||
if $CHECK_ONLY; then
|
if $CHECK_ONLY; then
|
||||||
check_for_updates
|
check_for_updates
|
||||||
exit $?
|
if $UPDATE_AVAILABLE; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
elif $UPDATE_MODE; then
|
elif $UPDATE_MODE; then
|
||||||
check_for_updates
|
check_for_updates
|
||||||
if [ $? -eq 1 ]; then
|
if $UPDATE_AVAILABLE; then
|
||||||
perform_update
|
perform_update
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user