git4pipi/clone-all.sh
2021-07-28 22:52:43 +02:00

35 lines
863 B
Bash
Executable File

#!/bin/bash
token=FgBxePzpabd+9D1EJWrZ4tEbY6UQ5QLFR+7tdrtfCqFbN210trnyAynByxlsb2voDkz1oR1yoZkPR9mMMwPxjw
liste=`curl https://admin.bernard.com.de/wtf/$token/list-readable-repos`
for path in $liste
do
if [ -f ./$path ]
then
echo "Vérification du repo $path"
if [[ ! -z $(git -C "./$path" status -s) ]]
then
echo "Le repository $path a des fichiers non enregistrés dans un commit... faudrait y corriger"
git -C "./$path" status
exit 1
fi
# Bon. on télécharge
if git -C "./$path" pull
then
/bin/true # Ou bien rien à merge, ou bien ca à marché.
else
# Impossible de merge
echo "Le repository $path a suivi un chemin de commits différent, il faut résoudre ça à la main."
exit 1
fi
# Enfin, on envoie nos changements
git -C "./$path" push --all
else
git clone git@bernard.com.de:$path ./$path
fi
done