chezmoi-shutdown-sync: no ocultar fallos de git commit/HEAD roto
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.
This commit is contained in:
@@ -13,6 +13,14 @@ echo "=== shutdown-sync $(date -Iseconds) ==="
|
|||||||
SRC="$HOME/.local/share/chezmoi"
|
SRC="$HOME/.local/share/chezmoi"
|
||||||
cd "$SRC" || exit 0
|
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
|
chezmoi re-add
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
@@ -21,7 +29,10 @@ if git diff --cached --quiet; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
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
|
if timeout 20 git push origin main; then
|
||||||
echo "push OK"
|
echo "push OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user