30 lines
705 B
Bash
Executable File
30 lines
705 B
Bash
Executable File
#!/bin/sh
|
|
# Translate different repo notations into ssh
|
|
# Usage:
|
|
# git repo <url>
|
|
# git repo <host> <repo> [user]
|
|
case "$1" in
|
|
(http*)
|
|
if expr "$1" : ".*:" >/dev/null
|
|
then echo "${1%/}" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|"
|
|
exit
|
|
else http=$1 && shift
|
|
fi;;
|
|
(git:*|ssh:*)
|
|
echo "$1"
|
|
exit;;
|
|
esac
|
|
host=$1
|
|
case $host in
|
|
(socha) user=software-challenge; host=github.com;;
|
|
(hub|github) host=github.com;;
|
|
(lab) host=gitlab.com;;
|
|
(ftt|"") host=forge.ftt.gmbh; user=janek;;
|
|
esac
|
|
user=${3:-${user:-$(git config user.name)}}
|
|
repo=${2:-$(basename $(git root))}
|
|
if test "$http"
|
|
then echo "$http://${host#git*@}/$user/$repo.git"
|
|
else echo "$host:$user/$repo.git"
|
|
fi
|