dotfiles/.local/bin/scripts/git-repo

30 lines
735 B
Plaintext
Raw Normal View History

#!/bin/sh
# Translate different repo notations into ssh
# Usage:
# git repo <url>
# git repo <host> <repo> [user]
case "$1" in
2022-08-21 10:29:51 +00:00
(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
2022-08-21 10:29:51 +00:00
case $1 in
(socha) user=software-challenge; host=git@github.com;;
(hub) host=git@github.com;;
(lab) host=git@gitlab.com;;
2023-03-13 14:34:16 +00:00
(jf) host=${1:-gitea@git.jfischer.org};;
(*|ftt) host=git@code.ftt.gmbh; user=janek;;
2022-08-21 10:29:51 +00:00
esac
user=${3:-${user:-$(git config user.name)}}
repo=${2:-$(basename $PWD)}
if test "$http"
then echo "$http://${host#git*@}/$user/$repo.git"
else echo "$host:$user/$repo.git"
fi