Skip to content

Instantly share code, notes, and snippets.

@reidmv
Forked from blkperl/sync-submodules
Created June 4, 2012 22:47
Show Gist options
  • Save reidmv/2871295 to your computer and use it in GitHub Desktop.
Save reidmv/2871295 to your computer and use it in GitHub Desktop.
#!/bin/sh
NEXUS=$HOME/supernexus
branch="PECVD_Master"
lock="/tmp/githooklock"
if mkdir $lock; then
echo "Locking nexus superproject succeeded" >&2
else
echo "Locking nexus superproject failed - exit" >&2
exit 1
fi
# Track latest changes to submodules
(
unset GIT_DIR
cd $NEXUS
git submodule sync
git submodule foreach --recursive "git clean -d -x -f"
git submodule foreach --recursive "git checkout $branch"
git submodule foreach --recursive "git fetch origin $branch"
git submodule foreach --recursive "git reset --hard origin/$branch"
if [ "`git status | wc -l`" -eq "2" ]; then
echo "No Changes for nexus superproject"
else
echo "Pushing changes to nexus superproject on $branch"
git commit -a -m "hook: Track latest changes to nexus"
git push origin $branch
fi
)
wait
rmdir $lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment