Skip to content

Instantly share code, notes, and snippets.

@kavyasukumar
Last active October 13, 2016 21:33
Show Gist options
  • Save kavyasukumar/2e8fbdcaf12375cd60c395d0a82f99a8 to your computer and use it in GitHub Desktop.
Save kavyasukumar/2e8fbdcaf12375cd60c395d0a82f99a8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# USAGE: bash -c "$(curl -fsSL https://gist.github.com/kavyasukumar/2e8fbdcaf12375cd60c395d0a82f99a8/raw/update-blueprints-shared.sh)" {NAME OF THE SHARED BRANCH} {COMMIT MESSAGE STRING}
shared_branch=$1
commit_msg=$2
repos=(
"autotune-quiz"
"autotune-personality-quiz"
"autotune-flowchart"
"autotune-chartmaker"
"autotune-sortable-table"
"autotune-diversity-chart"
"autotune-timeline"
)
echo "Cloning" ${#repos[@]} "repositories for updates"
for repo in "${repos[@]}"
do
if [ -d "${repo}" ]; then
cd "${repo}"
echo "Stashing any pending changes..."
git stash
else
git clone [email protected]:voxmedia/"${repo}".git
cd "${repo}"
fi
if (git branch -a --list "$shared_branch"); then
git checkout "$shared_branch"
else
git checkout -b "$shared_branch"
fi
if (git branch -r --list origin/"$shared_branch"); then
git pull origin "$shared_branch"
fi
git submodule update --init
cd shared
if (git branch -a --list "$shared_branch"); then
git checkout "$shared_branch"
else
git checkout -b "$shared_branch"
fi
if (git branch -r --list origin/"$shared_branch"); then
git pull origin "$shared_branch"
fi
cd ..
git add shared
git commit -m "$commit_msg"
git push origin "$shared_branch"
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment