Skip to content

Instantly share code, notes, and snippets.

@colinta
Created February 9, 2012 18:41
Show Gist options
  • Save colinta/1781914 to your computer and use it in GitHub Desktop.
Save colinta/1781914 to your computer and use it in GitHub Desktop.
Changes the origin from fusionbox-testing.com to dev.fusionbox.com
function confirm()
{
echo -n "$1 [y]" >&2
read yn
if [[ "$yn" != "n" ]]; then
echo 1
fi
}
if [[ -z `confirm "First, you need to \`cd\` into your projects folder. Have you done that?"` ]]; then
exit
fi
pwd=$PWD
for project in *
do
cd "$pwd"
if [[ -d "$project" ]]; then
cd $project
echo -n "Updating $project..."
current=$(git config remote.origin.url)
if [[ -z "$current" ]]; then
echo 'not a git repo'
elif [[ $current =~ dev.fusionbox.com ]]; then
echo 'already done'
elif [[ $current =~ fusionbox-testing|dev|fbt ]]; then
new=${current#[email protected]}
new=${new#git@dev}
new=${new#git@fbt}
new="[email protected]$new"
echo
if [[ -n `confirm "git config remote.origin.url '$new'"` ]]; then
git config remote.origin.url "$new"
fi
else
echo 'done'
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment