#!/bin/zsh -feu

# Once gitorious.org was dropped, and so I needed to drop "git remotes"
# from some repos.

# So, if a `remote' points at the `hostname', do replace by  ... mdell

# fixme: tries to connect so tcp timeout needed.

usage()
{
    echo <<EOF
usage: ${0##*/} [+-h]

EOF
}


while getopts :h OPT; do
    case $OPT in
        h|+h)
            usage()
            exit
            ;;
        *)
            usage
            exit 2
    esac
done
shift OPTIND-1
OPTIND=1

# mdell
hostname_rx="gitorious\\.org"
remote=origin

url=$(git remote get-url $remote)

echo $url
if expr match "$url" ".*@$hostname_rx";
then
    set -x
    git remote rm $remote
    git-add-remote-sibling -d
fi
