From 31fcc649532ad3e861ae68eceea0730da923b477 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 5 Jul 2022 12:15:47 +0200 Subject: [PATCH] bin/git-repo: add https flag --- .local/bin/scripts/git-repo | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.local/bin/scripts/git-repo b/.local/bin/scripts/git-repo index 0540159..fe845d3 100755 --- a/.local/bin/scripts/git-repo +++ b/.local/bin/scripts/git-repo @@ -3,15 +3,21 @@ # Usage: # git repo # git repo [user] +test "$1" = https && https=true && shift case "$1" in (http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;; - (git:*) echo "$1" ;; - (*) host=$1 + (git:*|ssh:*) echo "$1" ;; + (*) case $1 in (socha) user=software-challenge; host=git@github.com;; (hub) host=git@github.com;; (lab) host=git@gitlab.com;; - (*) host=$1;; + (*) host=${1:-gitea@git.jfischer.org};; esac - echo "${host:-gitea@git.jfischer.org}:${3:-${user:-$(git config user.name)}}/${2:-$(basename $PWD)}.git" ;; + 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 esac