#!/bin/sh

# clone only
[ $1 = "0000000000000000000000000000000000000000" -a $3 = "1" ] || exit 0

URL=$(git remote -v | awk '/(fetch)/ { print $2 }')

if [[ $URL = git@bitbucket.org:baggins/* ]]; then
	REPO=${URL#git@bitbucket.org:baggins/}
elif [[ $URL = git@github.com:janekr/* ]]; then
	REPO=${URL#git@github.com:janekr/}
else
	exit 0
fi

git remote set-url origin git@bitbucket.org:baggins/$REPO
git remote add github git@github.com:janekr/$REPO
git config --local --rename-section remote.origin remote.bitbucket
git config --local --add remote.origin.url git@bitbucket.org:baggins/$REPO
git config --local --add remote.origin.url git@github.com:janekr/$REPO
