Created
May 16, 2012 08:48
-
-
Save arjan/2708804 to your computer and use it in GitHub Desktop.
Automatically update and commit a parent repository when a submodule changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Arjan Scherpenisse, 2012-05-16 | |
# | |
# Automatically update and commit a parent repository when a submodule changed | |
DIR=$(dirname $PWD) | |
PART=$(basename $PWD) | |
cd .. | |
while [ "$DIR" != "/" ]; do | |
PARENTREPO=$(basename $DIR) | |
if [ -d "$DIR/.git" ]; then | |
if $(git diff $PART|grep "dirty" >/dev/null); then | |
echo "This repository is dirty, cannot updated parent repository $PARENTREPO."; | |
exit 1 | |
fi | |
git add $PART | |
git commit -m "Updated submodule `basename $PART`" | |
git push | |
echo "Commited and pushed to $PARENTREPO." | |
break | |
fi | |
PART="`basename $DIR`/$PART" | |
DIR=$(dirname $DIR) | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment