pgit.sh: Support --remote-base

pgit.sh has ssh://$login@git.janware.com/srv/git/$fromuser/proj/$reponame
hard-coded as the remote Git URLs of every cloned project.

This commit adds support for the global option --remote-base. Passing
it changes the URL to <remote-base>/$fromuser/$reponame..

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-11-18 15:25:46 +01:00
commit 1b21e33ded

View file

@ -144,15 +144,15 @@ clone()
continue continue
fi fi
cur=`expr $cur + 1` cur=`expr $cur + 1`
local pullurl=ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p local pullurl=$remote_base/$fromuser$remote_subpath/$p
local pushurl=ssh://$login@git.janware.com/srv/git/$login/proj/$p local pushurl=$remote_base/$login$remote_subpath/$p
local curref="" local curref=""
fat_marker "Fetching project $p from user $fromuser" fat_marker "Fetching project $p from user $fromuser"
if [ "$fromuser" = "$login" ]; then if [ "$fromuser" = "$login" ]; then
if [ -d $p ]; then if [ -d $p ]; then
run_git -C $p pull --recurse-submodules=on-demand run_git -C $p pull --recurse-submodules=on-demand
else else
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p run_git clone $remote_base/$fromuser$remote_subpath/$p
fi fi
else else
local remotename="jw-$fromuser" local remotename="jw-$fromuser"
@ -172,7 +172,7 @@ clone()
fi fi
else else
# set -x # set -x
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p run_git clone $remote_base/$fromuser$remote_subpath/$p
run_git -C $p remote rename origin $remotename || fatal failed to rename remote in $p run_git -C $p remote rename origin $remotename || fatal failed to rename remote in $p
run_git -C $p remote set-url --push $remotename no_push run_git -C $p remote set-url --push $remotename no_push
if [ $create_remote_user_repos = true ]; then if [ $create_remote_user_repos = true ]; then
@ -205,6 +205,25 @@ echo "running $0 $@ GIT_SSH=$GIT_SSH" >&2
SSH=ssh SSH=ssh
[ "$GIT_SSH" ] && SSH=$GIT_SSH [ "$GIT_SSH" ] && SSH=$GIT_SSH
remote_base="ssh://$login@git.janware.com/srv/git"
while [ ${1:0:1} = - ]; do
case $1 in
'--remote-base')
remote_base="$2"
shift
;;
esac
shift
done
# Only janware.com ssh git supports subdirectories below users
if [[ "$remote_base" =~ git.janware.com ]]; then
remote_subpath="/proj"
else
remote_subpath=""
fi
cmd=$1 cmd=$1
cur=0 cur=0
shift shift