Skip to content

Instantly share code, notes, and snippets.

@gedex
Created October 3, 2016 09:02
Show Gist options
  • Save gedex/2d450f679ba1b33302685ef643c2e12f to your computer and use it in GitHub Desktop.
Save gedex/2d450f679ba1b33302685ef643c2e12f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Store current directory.
CUR_DIR=$(pwd)
default_old_gh_org="woothemes"
default_new_gh_org="woocommerce"
default_plugins_dir="$CUR_DIR"
echo "Your WP_PLUGIN_DIR. No trailing slash."
printf "($default_plugins_dir):"
read -e input
input="${input%/}"
PLUGINS_DIR="${input:-$default_plugins_dir}"
echo
echo "Old GH Organization to replace."
printf "($default_old_gh_org):"
read -e input
OLD_GH_ORG="${input:-$default_old_gh_org}"
echo
echo "New GH Organization."
printf "($default_new_gh_org):"
read -e input
NEW_GH_ORG="${input:-$default_new_gh_org}"
echo
function update_git_remote {
cd $1
origin=`git remote get-url origin`
if [[ $origin == [email protected]:$OLD_GH_ORG/* ]]; then
new_origin="${origin/$OLD_GH_ORG/$NEW_GH_ORG}"
echo "New origin $new_origin"
git remote set-url origin $new_origin
fi
cd $PLUGINS_DIR
}
for plugin in $PLUGINS_DIR/*; do
if [ -d "$plugin/.git" ]; then
update_git_remote $plugin
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment