Last active
December 17, 2015 04:49
-
-
Save whitekid/5553143 to your computer and use it in GitHub Desktop.
git submodule commit / push script
This file contains 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 | |
# submodule commit/push | |
set -e | |
submodules=`git submodule status | awk '{print $2}'` | |
command="$1" | |
shift | |
args="$@" | |
function apply_here(){ | |
case $command in | |
commit) | |
! git status | grep -q '^nothing to commit' | |
;; | |
push) | |
git status | grep -q '# Your branch is ahead of ' | |
;; | |
*) | |
echo "command $command not supported" | |
exit | |
;; | |
esac | |
} | |
for submodule in $submodules; do | |
echo "==== submodule $submodule ====" | |
pushd `pwd` > /dev/null | |
cd $submodule | |
if apply_here; then | |
popd > /dev/null | |
continue | |
fi | |
git $command $args | |
popd > /dev/null | |
done | |
# vim: ai nu aw | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment