Skip to content

Instantly share code, notes, and snippets.

@cloudnull
Created November 5, 2013 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudnull/7322922 to your computer and use it in GitHub Desktop.
Save cloudnull/7322922 to your computer and use it in GitHub Desktop.
Super-Duper Submodule updater. Used for updating a mess of sub-modules which belong to the RCBOPS chef-cookbooks repo.
#!/usr/bin/env bash
# This is the SUPER SUBMODULE UPDATE!
# To use this you HAVE TO BE IN THE "chef-cookbooks" directory.
set -e
set -u
BRANCH=${BRANCH:-master}
if [ -d "cookbooks" ];then
pushd cookbooks
for obj in *;do
if [ -d "${obj}" ];then
pushd ${obj}
if [ -d ".git" ] || [ -f ".git" ];then
RCB=$(git remote -v | grep -i rcbops | awk '/fetch/ {print $1}')
if [ "${RCB}" ];then
echo "Updating ${obj} repo from ${BRANCH}"
git checkout ${BRANCH}
git pull ${RCB} ${BRANCH}
fi
else
echo "Not a Git repo"
fi
popd
fi
done
popd
else
echo "You can't follow instructions. You need to be in the chef-cookbooks directory"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment