From b6aae0348dd657cedee7bbca4a9a4c0f4e74830f Mon Sep 17 00:00:00 2001 From: Josevi Date: Tue, 18 Aug 2026 11:04:22 +0200 Subject: [PATCH] chezmoi-shutdown-sync: no ocultar fallos de git commit/HEAD roto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Antes: si HEAD no resolvía (objeto corrupto) o 'git commit' fallaba, el script seguía adelante y 'git push' acababa diciendo 'push OK' sin haber respaldado nada de verdad -- así estuvo una semana en silencio. Ahora aborta con aviso claro en el log en vez de fingir éxito. --- dot_local/bin/executable_chezmoi-shutdown-sync.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dot_local/bin/executable_chezmoi-shutdown-sync.sh b/dot_local/bin/executable_chezmoi-shutdown-sync.sh index 8168e25..d511434 100644 --- a/dot_local/bin/executable_chezmoi-shutdown-sync.sh +++ b/dot_local/bin/executable_chezmoi-shutdown-sync.sh @@ -13,6 +13,14 @@ echo "=== shutdown-sync $(date -Iseconds) ===" SRC="$HOME/.local/share/chezmoi" cd "$SRC" || exit 0 +# Comprobación de salud antes de tocar nada: un HEAD que no resuelve (objeto +# corrupto en disco, etc.) hace que git diff/commit fallen en silencio más +# abajo y el script acababa diciendo "push OK" sin haber respaldado nada. +if ! git rev-parse --verify --quiet HEAD >/dev/null; then + echo "!! repo git roto (HEAD no resuelve) -- reparación manual necesaria, no se toca nada" + exit 1 +fi + chezmoi re-add git add -A @@ -21,7 +29,10 @@ if git diff --cached --quiet; then exit 0 fi -git commit -m "Auto-backup $(date '+%Y-%m-%d %H:%M')" +if ! git commit -m "Auto-backup $(date '+%Y-%m-%d %H:%M')"; then + echo "!! git commit falló -- revisa el repo a mano, los cambios quedan sin respaldar" + exit 1 +fi if timeout 20 git push origin main; then echo "push OK"