55 lines
1.6 KiB
Bash
55 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|||
|
|
# Clona (o aggiorna) il generatore di dati di prova gen_data in extern/gen_data, cartella ignorata da git.
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
cd "$(dirname "$0")"
|
||
|
|
|
||
|
|
URL_DEFAULT="https://santantonio.sytes.net/cevolani/gen_data.git"
|
||
|
|
DEST="extern/gen_data"
|
||
|
|
|
||
|
|
uso() {
|
||
|
|
cat <<E2
|
||
|
|
uso: ./scarica_gen_data.sh [-u] [-h]
|
||
|
|
|
||
|
|
Clona $URL_DEFAULT in $DEST (cartella ignorata da git: non fa parte di questo repository).
|
||
|
|
Servono i file genera.py e config.toml: tests/test_validazione.py li cerca lì e, se mancano, salta i test.
|
||
|
|
Per usare un altro indirizzo (es. SSH) imposta GEN_DATA_URL.
|
||
|
|
|
||
|
|
opzioni:
|
||
|
|
-u, --aggiorna se la cartella esiste già, la porta all'ultima versione (git pull --ff-only)
|
||
|
|
-h, --help mostra questo aiuto
|
||
|
|
|
||
|
|
esempi:
|
||
|
|
./scarica_gen_data.sh
|
||
|
|
./scarica_gen_data.sh -u
|
||
|
|
GEN_DATA_URL=ssh://git@santantonio.sytes.net:2223/cevolani/gen_data.git ./scarica_gen_data.sh
|
||
|
|
E2
|
||
|
|
}
|
||
|
|
|
||
|
|
aggiorna=0
|
||
|
|
for a in "$@"; do
|
||
|
|
case "$a" in
|
||
|
|
-u|--aggiorna) aggiorna=1 ;;
|
||
|
|
-h|--help) uso; exit 0 ;;
|
||
|
|
*) echo "scarica_gen_data.sh: opzione non riconosciuta: $a" >&2; uso >&2; exit 2 ;;
|
||
|
|
esac
|
||
|
|
done
|
||
|
|
|
||
|
|
url=${GEN_DATA_URL:-$URL_DEFAULT}
|
||
|
|
|
||
|
|
if [ -d "$DEST/.git" ]; then
|
||
|
|
if [ "$aggiorna" -eq 1 ]; then
|
||
|
|
git -C "$DEST" pull --ff-only
|
||
|
|
else
|
||
|
|
echo "$DEST esiste già (usa -u per aggiornarlo)"
|
||
|
|
fi
|
||
|
|
elif [ -e "$DEST" ]; then
|
||
|
|
echo "scarica_gen_data.sh: $DEST esiste e non è un repository git" >&2
|
||
|
|
exit 1
|
||
|
|
else
|
||
|
|
mkdir -p extern
|
||
|
|
git clone "$url" "$DEST"
|
||
|
|
fi
|
||
|
|
|
||
|
|
[ -f "$DEST/genera.py" ] || { echo "scarica_gen_data.sh: $DEST/genera.py non trovato" >&2; exit 1; }
|
||
|
|
echo "pronto: $DEST ($(git -C "$DEST" rev-parse --short HEAD))"
|