From f9f004179070e115caea4c7e6b645f1cc4ec88ef Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 24 Nov 2025 10:35:07 +0100 Subject: [PATCH] pgit.sh: Support --login In the move away from environment variables, replace JANWARE_USER support in pgit.sh by the --login option. Signed-off-by: Jan Lindemann --- make/projects-dir.mk | 13 ++++++++----- scripts/pgit.sh | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/make/projects-dir.mk b/make/projects-dir.mk index dd80bcf3..ddb5e7b2 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -118,7 +118,10 @@ PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OP PGIT_SH := /bin/bash $(JWB_SCRIPT_DIR)/pgit.sh PGIT_SH_CLONE := $(PGIT_SH) clone -PGIT_SH_CLONE_DEFAULT := $(PGIT_SH_CLONE) +PGIT_SH_CLONE_DEFAULT = $(PGIT_SH_CLONE) $(PGIT_SH_OPTS_NETWORK) +ifneq ($(JANWARE_USER),) + PGIT_SH_OPTS_NETWORK += --login $(JANWARE_USER) +endif ifneq ($(CLONE_FROM_USER),) PGIT_SH_CLONE_DEFAULT += --refspec $(CLONE_FROM_USER) endif @@ -296,10 +299,10 @@ diff-all diff: $(SSH_WRAPPER_SH) $(PGIT_SH) diff git-push push: $(SSH_WRAPPER_SH) - $(PGIT_SH) push + $(PGIT_SH) push $(PGIT_SH_OPTS_NETWORK) git-push-all: $(SSH_WRAPPER_SH) - $(PGIT_SH) push --all --recurse-submodules=on-demand + $(PGIT_SH) push $(PGIT_SH_OPTS_NETWORK) --all --recurse-submodules=on-demand git-diff: $(SSH_WRAPPER_SH) $(PGIT_SH) diff @@ -318,7 +321,7 @@ git-pull-mini: $(SSH_WRAPPER_SH) PGIT_CLONE_PROJECTS="$(patsubst %/.git,%,$(wildcard $(addsuffix /.git,$(shell make -s build-order))))" $(PGIT_SH_CLONE_DEFAULT) git-pull-all: $(SSH_WRAPPER_SH) - $(PGIT_SH) pull --all + $(PGIT_SH) pull $(PGIT_SH_OPTS_NETWORK) --all git-clone: $(SSH_WRAPPER_SH) $(PGIT_SH_CLONE_DEFAULT) @@ -346,7 +349,7 @@ git-update-project-descriptions: $(SSH_WRAPPER_SH) $(GIT_SRV_ADMIN_SH) -j update-descriptions all git-pull-%: $(SSH_WRAPPER_SH) - $(PGIT_SH_CLONE) --refspec "$*:master:master" + $(PGIT_SH_CLONE) $(PGIT_SH_OPTS_NETWORK) --refspec "$*:master:master" git-commit: $(PGIT_SH) commit diff --git a/scripts/pgit.sh b/scripts/pgit.sh index e1b14625..5168930f 100644 --- a/scripts/pgit.sh +++ b/scripts/pgit.sh @@ -101,9 +101,9 @@ clone() } local p + local whoami="$(id -un)" config cd $pdir - local login=$JANWARE_USER local projects="$PGIT_CLONE_PROJECTS" local ignore="$PGIT_IGNORE" local thisdir="${0%/*}" @@ -112,6 +112,8 @@ clone() local long_opts="create-remote-user-repos" local refspec=() long_opts="$long_opts,refspec:" + local login="$whoami" + long_opts="$long_opts,login:" local opts opts=$(getopt -o C --long "$long_opts" -n clone -- "$@") || fatal "Failed to parse options $@" @@ -125,6 +127,10 @@ clone() refspec=(${2//:/ }) shift ;; + --login) + login="$2" + shift + ;; *) fatal "Unknown option $1" ;; @@ -136,8 +142,6 @@ clone() local fromuser="${refspec[0]}" local fromref="${refspec[1]}" local toref="${refspec[2]}" - local whoami="$(id -un)" - [ "$login" ] || login=$whoami [ "$fromuser" ] || fromuser=$whoami [ "$fromref" ] || fromref=master local git_srv_admin="$SSH $login@git.janware.com /opt/jw-build/bin/git-srv-admin.sh"