You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scripts/update_all_submodules

43 lines
899 B

#!/bin/bash
PARENTDIR=$PWD
echo "Working in $PARENTDIR"
if [[ ! -d .git ]]; then
echo "Current directory does not contain a .git folder. Exiting..."
exit 1
fi
git pull
git reset --hard HEAD
git clean -d -x -f
exec 3< submodules
while read <&3
do
cd $PARENTDIR
DIR2UPDATE=$REPLY
if [[ $DIR2UPDATE != "" ]]; then
echo "Attempting to reset submodule $DIR2UPDATE"
cd $PARENTDIR/$DIR2UPDATE/..
while [[ ! -d .git ]]; do
cd ../
done
git submodule init
git submodule update
cd $PARENTDIR/$DIR2UPDATE
git reset --hard HEAD
git clean -d -x -f
git checkout master
git pull
cd ..
while [[ ! -d .git ]]; do
cd ../
done
echo "Committing changes to $PWD"
# git commit -a -m "Reset submodule to latest HEAD"
git add $PARENTDIR/$DIR2UPDATE
git commit $PARENTDIR/$DIR2UPDATE -m "Reset submodule $DIR2UPDATE to latest HEAD"
git push origin master
fi
done
exec 3>&-