Skip to content

Instantly share code, notes, and snippets.

@gedex
Created October 3, 2016 09:04
Show Gist options
  • Save gedex/6de7de08281f3254ece9280b6e9f2ba7 to your computer and use it in GitHub Desktop.
Save gedex/6de7de08281f3254ece9280b6e9f2ba7 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
cd $CUR_DIR
@gedex
Copy link
Author

gedex commented Oct 3, 2016

Running it with wget:

bash <(wget -qO- https://gist.github.com/gedex/6de7de08281f3254ece9280b6e9f2ba7/raw/3a7d8f756a62c7a75136410d91b35f665e3b377a/update-gh-org-remote.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment