pgit.sh: clone --login configures broken remote

pgit.sh clone --login <username> fails to insert said username into a
remotes url while adding it: Of ssh://<username>@git.janware.com/srv/git,
only ssh://@git.janware.com/srv/git makes it into the config. Fix
that.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-11-26 20:00:51 +01:00
commit 0d95ccc5a0

View file

@ -100,6 +100,8 @@ clone()
fi
}
local remote_base="$global_remote_base"
local remote_subpath="$global_remote_subpath"
local p
local whoami="$(id -un)"
config
@ -151,6 +153,11 @@ clone()
[ "$?" != 0 ] && exit 1
fi
if [ "$login" ]; then
[ "${remote_base/@/}" = "${remote_base}" ] || fatal "Specified both --login $login and user in URL $remote_base"
remote_base=$(echo $remote_base | sed "s|://|://$login@|")
fi
n_projects=`echo $projects | wc -w`
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
for p in $projects; do
@ -219,12 +226,12 @@ echo "running $0 $@ GIT_SSH=$GIT_SSH" >&2
SSH=ssh
[ "$GIT_SSH" ] && SSH=$GIT_SSH
remote_base="ssh://$login@git.janware.com/srv/git"
global_remote_base="ssh://git.janware.com/srv/git"
while [ ${1:0:1} = - ]; do
case $1 in
'--remote-base')
remote_base="$2"
global_remote_base="$2"
shift
;;
esac
@ -232,10 +239,10 @@ while [ ${1:0:1} = - ]; do
done
# Only janware.com ssh git supports subdirectories below users
if [[ "$remote_base" =~ git.janware.com ]]; then
remote_subpath="/proj"
if [[ "$global_remote_base" =~ git.janware.com ]]; then
global_remote_subpath="/proj"
else
remote_subpath=""
global_remote_subpath=""
fi
cmd=$1