2021-06-18 15:51:57 +00:00
|
|
|
#!/bin/sh
|
2021-11-06 23:22:45 +00:00
|
|
|
# Translate different repo notations into ssh
|
|
|
|
# Usage:
|
|
|
|
# git repo <url>
|
|
|
|
# git repo <host> <repo> [user]
|
2022-07-05 10:15:47 +00:00
|
|
|
test "$1" = https && https=true && shift
|
2021-06-18 15:51:57 +00:00
|
|
|
case "$1" in
|
2021-11-06 23:22:45 +00:00
|
|
|
(http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;;
|
2022-07-05 10:15:47 +00:00
|
|
|
(git:*|ssh:*) echo "$1" ;;
|
|
|
|
(*)
|
2021-11-17 14:55:46 +00:00
|
|
|
case $1 in
|
2021-12-16 22:04:50 +00:00
|
|
|
(socha) user=software-challenge; host=git@github.com;;
|
2021-11-17 14:55:46 +00:00
|
|
|
(hub) host=git@github.com;;
|
|
|
|
(lab) host=git@gitlab.com;;
|
2022-07-05 10:15:47 +00:00
|
|
|
(*) host=${1:-gitea@git.jfischer.org};;
|
2021-11-17 14:55:46 +00:00
|
|
|
esac
|
2022-07-05 10:15:47 +00:00
|
|
|
user=${3:-${user:-$(git config user.name)}}
|
|
|
|
repo=${2:-$(basename $PWD)}
|
|
|
|
if test "$https"
|
|
|
|
then echo "https://${host#git*@}/$user/$repo"
|
|
|
|
else echo "$host:$user/$repo.git"
|
|
|
|
fi
|
2021-06-18 15:51:57 +00:00
|
|
|
esac
|