2021-06-18 17:51:57 +02:00
|
|
|
#!/bin/sh
|
2021-11-07 00:22:45 +01:00
|
|
|
# Translate different repo notations into ssh
|
|
|
|
# Usage:
|
|
|
|
# git repo <url>
|
|
|
|
# git repo <host> <repo> [user]
|
2021-06-18 17:51:57 +02:00
|
|
|
case "$1" in
|
2022-08-21 12:29:51 +02:00
|
|
|
(http*)
|
|
|
|
if expr "$1" : ".*:" >/dev/null
|
2023-06-16 10:47:24 +02:00
|
|
|
then echo "${1%/}" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|"
|
2022-08-21 12:29:51 +02:00
|
|
|
exit
|
|
|
|
else http=$1 && shift
|
|
|
|
fi;;
|
|
|
|
(git:*|ssh:*)
|
|
|
|
echo "$1"
|
|
|
|
exit;;
|
2021-06-18 17:51:57 +02:00
|
|
|
esac
|
2024-01-12 19:53:07 +03:00
|
|
|
host=$1
|
|
|
|
case $host in
|
2024-07-27 12:22:30 +03:00
|
|
|
(socha) user=software-challenge; host=github.com;;
|
|
|
|
(hub|github) host=github.com;;
|
|
|
|
(lab) host=gitlab.com;;
|
|
|
|
(ftt|"") host=forge.ftt.gmbh; user=janek;;
|
2022-08-21 12:29:51 +02:00
|
|
|
esac
|
|
|
|
user=${3:-${user:-$(git config user.name)}}
|
2023-09-27 15:38:23 +02:00
|
|
|
repo=${2:-$(basename $(git root))}
|
2022-08-21 12:29:51 +02:00
|
|
|
if test "$http"
|
|
|
|
then echo "$http://${host#git*@}/$user/$repo.git"
|
|
|
|
else echo "$host:$user/$repo.git"
|
|
|
|
fi
|