Created
November 5, 2013 17:35
-
-
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.
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
#!/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