Skip to content

Instantly share code, notes, and snippets.

@jlafourc
Last active August 29, 2015 13:56
Show Gist options
  • Save jlafourc/8955842 to your computer and use it in GitHub Desktop.
Save jlafourc/8955842 to your computer and use it in GitHub Desktop.
Migration Forge
#!/bin/bash
declare -A repository_list;
repository_list[[email protected]:agrhum.git][email protected]:referentiel/agrhum.git
depart=`pwd`;
echo "L'origine des dépots suivants seront modifiés";
echo "---------------------------------------------";
for d in `find . -name .git -type d -exec readlink -f {}/.. \;`
do
cd $d;
url=`git config --get remote.origin.url`;
if [[ ${repository_list[$url]} ]]; then
echo $d : $url "->" ${repository_list[$url]};
fi
done
echo -e "\n----\n";
cd $depart;
echo -n "Voulez-vous vraiment appliquer ces modifications [O/n][defaut n]: ";
read choix;
if [[ $choix == "O" ]]; then
for d in `find . -name .git -type d -exec readlink -f {}/.. \;`
do
cd $d;
url=`git config --get remote.origin.url`;
if [[ ${repository_list[$url]} ]]; then
git remote set-url origin ${repository_list[$url]}
echo $d : Fait;
fi
done
else
if [[ -z $choix ]] || [[ $choix == "n" ]]; then
echo "Ah ! Je fais rien, tant pis ...";
else
echo "Boulet !!!";
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment