ITSERR_workbench/push_in_chunks_ii.sh

49 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -e
BASE="02_da_classificare/__Deliverables"
# Trova tutte le cartelle reali, anche con spazi, parentesi, UTF-8 ecc.
# Le virgolette sono fondamentali.
mapfile -t dirs < <(find "$BASE" -maxdepth 1 -mindepth 1 -type d | sort)
echo "Trovate cartelle:"
printf ' - %s\n' "${dirs[@]}"
echo
echo "Avvio commit+push per ogni pezzo..."
echo
for d in "${dirs[@]}"; do
echo "------------------------------------------------------------"
echo "Processing: $d"
echo "------------------------------------------------------------"
# Aggiungi SOLO quella cartella (con virgolette!)
git add "$d"
# Se non ci sono modifiche → salto
if git diff --cached --quiet; then
echo "Nessuna modifica in $d → salto."
continue
fi
# Commit sicuro
msg="Commit automatico: $(basename "$d")"
git commit -m "$msg"
# Push
echo "Pusho..."
if git push; then
echo "OK → $d"
else
echo "❌ ERRORE su $d → lo annullo e continuo..."
git reset HEAD~1
fi
echo
done
echo "------------------------------------------------------------"
echo "Processo completato."