#!/bin/sh
# Translate different repo notations into ssh
# Usage:
#  git repo <url>
#  git repo <host> <repo> [user]
case "$1" in
  (http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;;
  (git:*) echo "$1" ;;
  (*) host=$1
    case $1 in
      (socha) user=software-challenge; host=git@github.com;;
      (hub) host=git@github.com;;
      (lab) host=git@gitlab.com;;
      (*) host=$1;;
    esac
    echo "${host:-git.jfischer.org}:${3:-${user:-$(git config user.name)}}/${2:-$(basename $PWD)}.git" ;;
esac