mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
pgit.sh: Support --refspec
In the attempt to move away from communicating options via environment variables from one part of jw-build software to another, replace PGIT_CLONE_FROM_USER with the clearer --refspec option. Which is also more versatile. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c6444a4a72
commit
d047ad650c
2 changed files with 32 additions and 21 deletions
|
|
@ -116,14 +116,17 @@ endif
|
||||||
PROJECTS_PY = $(TIME) python3 $(JWB_SCRIPT_DIR)/jw-projects.py --prefix $(shell pwd) $(PROJECTS_PY_EXTRA_OPTS)
|
PROJECTS_PY = $(TIME) python3 $(JWB_SCRIPT_DIR)/jw-projects.py --prefix $(shell pwd) $(PROJECTS_PY_EXTRA_OPTS)
|
||||||
PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OPTS)
|
PROJECTS_PY_BUILD = $(PROJECTS_PY) build $(PROJECTS_PY_EXTRA_BUILD_OPTS)
|
||||||
|
|
||||||
PGIT_SH = /bin/bash $(JWB_SCRIPT_DIR)/pgit.sh
|
PGIT_SH := /bin/bash $(JWB_SCRIPT_DIR)/pgit.sh
|
||||||
PGIT_SH_CLONE = $(PGIT_SH) clone
|
PGIT_SH_CLONE := $(PGIT_SH) clone
|
||||||
export PGIT_CLONE_FROM_USER = $(CLONE_FROM_USER)
|
PGIT_SH_CLONE_DEFAULT := $(PGIT_SH_CLONE)
|
||||||
|
ifneq ($(CLONE_FROM_USER),)
|
||||||
|
PGIT_SH_CLONE_DEFAULT += --refspec $(CLONE_FROM_USER)
|
||||||
|
endif
|
||||||
ifneq ($(OFFLINE_PROJECTS),)
|
ifneq ($(OFFLINE_PROJECTS),)
|
||||||
export PGIT_IGNORE = $(OFFLINE_PROJECTS)
|
export PGIT_IGNORE = $(OFFLINE_PROJECTS)
|
||||||
endif
|
endif
|
||||||
ifneq ($(JANWARE_USER),)
|
ifneq ($(JANWARE_USER),)
|
||||||
#PGIT_SH_CLONE += --create-remote-user-repos
|
#PGIT_SH_CLONE_DEFAULT += --create-remote-user-repos
|
||||||
endif
|
endif
|
||||||
ifneq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
|
ifneq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
|
||||||
PGIT_SH += --remote-base $(PROJECTS_DIR_REMOTE_BASE)
|
PGIT_SH += --remote-base $(PROJECTS_DIR_REMOTE_BASE)
|
||||||
|
|
@ -309,20 +312,20 @@ git-status:
|
||||||
|
|
||||||
|
|
||||||
git-pull: $(SSH_WRAPPER_SH)
|
git-pull: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH_CLONE)
|
$(PGIT_SH_CLONE_DEFAULT)
|
||||||
|
|
||||||
git-pull-mini: $(SSH_WRAPPER_SH)
|
git-pull-mini: $(SSH_WRAPPER_SH)
|
||||||
PGIT_CLONE_PROJECTS="$(patsubst %/.git,%,$(wildcard $(addsuffix /.git,$(shell make -s build-order))))" $(PGIT_SH_CLONE)
|
PGIT_CLONE_PROJECTS="$(patsubst %/.git,%,$(wildcard $(addsuffix /.git,$(shell make -s build-order))))" $(PGIT_SH_CLONE_DEFAULT)
|
||||||
|
|
||||||
git-pull-all: $(SSH_WRAPPER_SH)
|
git-pull-all: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH) pull --all
|
$(PGIT_SH) pull --all
|
||||||
|
|
||||||
git-clone: $(SSH_WRAPPER_SH)
|
git-clone: $(SSH_WRAPPER_SH)
|
||||||
$(PGIT_SH_CLONE)
|
$(PGIT_SH_CLONE_DEFAULT)
|
||||||
touch clone.done
|
touch clone.done
|
||||||
|
|
||||||
git-clone-%: $(SSH_WRAPPER_SH)
|
git-clone-%: $(SSH_WRAPPER_SH)
|
||||||
PGIT_CLONE_FROM_USER=$* $(PGIT_SH_CLONE)
|
$(PGIT_SH_CLONE_DEFAULT)
|
||||||
|
|
||||||
git-show-non-master-branches:
|
git-show-non-master-branches:
|
||||||
@$(PGIT_SH) branch 2>&1 | \
|
@$(PGIT_SH) branch 2>&1 | \
|
||||||
|
|
@ -343,7 +346,7 @@ git-update-project-descriptions: $(SSH_WRAPPER_SH)
|
||||||
$(GIT_SRV_ADMIN_SH) -j update-descriptions all
|
$(GIT_SRV_ADMIN_SH) -j update-descriptions all
|
||||||
|
|
||||||
git-pull-%: $(SSH_WRAPPER_SH)
|
git-pull-%: $(SSH_WRAPPER_SH)
|
||||||
PGIT_CLONE_FROM_USER=$* $(PGIT_SH_CLONE)
|
$(PGIT_SH_CLONE) --refspec "$*:master:master"
|
||||||
|
|
||||||
git-commit:
|
git-commit:
|
||||||
$(PGIT_SH) commit
|
$(PGIT_SH) commit
|
||||||
|
|
@ -363,5 +366,5 @@ pull.done: $(filter-out $(UNAVAILABLE_TARGETS), clone.done)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
clone.done: $(filter-out $(UNAVAILABLE_TARGETS),$(SSH_WRAPPER_SH))
|
clone.done: $(filter-out $(UNAVAILABLE_TARGETS),$(SSH_WRAPPER_SH))
|
||||||
$(PGIT_SH_CLONE)
|
$(PGIT_SH_CLONE_DEFAULT)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
|
||||||
|
|
@ -103,30 +103,28 @@ clone()
|
||||||
local p
|
local p
|
||||||
config
|
config
|
||||||
cd $pdir
|
cd $pdir
|
||||||
local refspec=(${PGIT_CLONE_FROM_USER//:/ })
|
|
||||||
local fromuser=${refspec[0]}
|
|
||||||
local fromref=${refspec[1]}
|
|
||||||
local toref=${refspec[2]}
|
|
||||||
local login=$JANWARE_USER
|
local login=$JANWARE_USER
|
||||||
local projects="$PGIT_CLONE_PROJECTS"
|
local projects="$PGIT_CLONE_PROJECTS"
|
||||||
local ignore="$PGIT_IGNORE"
|
local ignore="$PGIT_IGNORE"
|
||||||
local thisdir="${0%/*}"
|
local thisdir="${0%/*}"
|
||||||
local jw_projects="/usr/bin/python3 $thisdir/jw-projects.py"
|
local jw_projects="/usr/bin/python3 $thisdir/jw-projects.py"
|
||||||
local create_remote_user_repos=false
|
local create_remote_user_repos=false
|
||||||
|
local long_opts="create-remote-user-repos"
|
||||||
[ "$login" ] || login=`whoami`
|
local refspec=()
|
||||||
[ "$fromuser" ] || fromuser=`whoami`
|
long_opts="$long_opts,refspec:"
|
||||||
[ "$fromref" ] || fromref=master
|
|
||||||
local git_srv_admin="$SSH $login@git.janware.com /opt/jw-build/bin/git-srv-admin.sh"
|
|
||||||
|
|
||||||
local opts
|
local opts
|
||||||
opts=$(getopt -o C --long create-remote-user-repos -n clone -- "$@") || fatal "Failed to parse options $@"
|
opts=$(getopt -o C --long "$long_opts" -n clone -- "$@") || fatal "Failed to parse options $@"
|
||||||
eval set -- "$opts"
|
eval set -- "$opts"
|
||||||
while [ "$1" != -- ]; do
|
while [ "$1" != -- ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-c | --create-remote-user-repos)
|
-C | --create-remote-user-repos)
|
||||||
create_remote_user_repos=true
|
create_remote_user_repos=true
|
||||||
;;
|
;;
|
||||||
|
--refspec)
|
||||||
|
refspec=(${2//:/ })
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
fatal "Unknown option $1"
|
fatal "Unknown option $1"
|
||||||
;;
|
;;
|
||||||
|
|
@ -135,10 +133,20 @@ clone()
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
if [ -z "$projects" ]; then
|
if [ -z "$projects" ]; then
|
||||||
projects=`$jw_projects list-repos --from-user $fromuser $remote_base`
|
projects=`$jw_projects list-repos --from-user $fromuser $remote_base`
|
||||||
[ "$?" != 0 ] && exit 1
|
[ "$?" != 0 ] && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
n_projects=`echo $projects | wc -w`
|
n_projects=`echo $projects | wc -w`
|
||||||
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
|
if [ "$PGIT_KEEP_GOING" != y ]; then set -e; fi
|
||||||
for p in $projects; do
|
for p in $projects; do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue