mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
pgit.sh: Add support for target refspec to PGIT_CLONE_FROM_USER
PGIT_CLONE_CLONE_FROM_USER now supports optional suffixes of the form [:src-ref[:dst-ref]]. If present, src-ref specifies the remote branch pgit.sh tries to fetch, and dst-ref the local branch it tries to fetch into. src-ref defaults to "master" (as it was before) and dst-ref to nothing, i.e. no head-update of any local branch. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
34c5d3ec21
commit
17244e9a3f
1 changed files with 16 additions and 4 deletions
|
|
@ -107,11 +107,15 @@ clone()
|
|||
local p
|
||||
config
|
||||
cd $pdir
|
||||
local fromuser=$PGIT_CLONE_FROM_USER
|
||||
local refspec=(${PGIT_CLONE_FROM_USER//:/ })
|
||||
local fromuser=${refspec[0]}
|
||||
local fromref=${refspec[1]}
|
||||
local toref=${refspec[2]}
|
||||
local login=$JANWARE_USER
|
||||
local projects="$PGIT_CLONE_PROJECTS"
|
||||
[ "$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
|
||||
projects=`$git_srv_admin -u $fromuser -j list-personal-projects`
|
||||
|
|
@ -123,6 +127,7 @@ clone()
|
|||
cur=`expr $cur + 1`
|
||||
local pullurl=ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
local pushurl=ssh://$login@git.janware.com/srv/git/$login/proj/$p
|
||||
local curref=""
|
||||
fat_marker "Fetching project $p from user $fromuser"
|
||||
if [ "$fromuser" = "$login" ]; then
|
||||
if [ -d $p ]; then
|
||||
|
|
@ -130,7 +135,6 @@ clone()
|
|||
else
|
||||
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
fi
|
||||
run_git -C $p submodule update --init --recursive || fatal git submodule update failed in $p
|
||||
else
|
||||
local remotename="jw-$fromuser"
|
||||
if [ -d $p ]; then
|
||||
|
|
@ -138,7 +142,15 @@ clone()
|
|||
run_git -C $p remote add $remotename $pullurl
|
||||
run_git -C $p remote set-url --push $remotename no_push
|
||||
}
|
||||
run_git -C $p fetch --recurse-submodules=on-demand $remotename master
|
||||
run_git -C $p fetch --prune --recurse-submodules=on-demand $remotename $fromref
|
||||
if [ "$toref" ]; then
|
||||
curref=`git -C $p branch --show-current`
|
||||
if [ "$curref" = "$toref" ]; then
|
||||
run_git -C $p pull --recurse-submodules=on-demand $remotename $fromref
|
||||
else
|
||||
run_git -C $p fetch --recurse-submodules=on-demand $remotename $fromref:$toref
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# set -x
|
||||
run_git clone ssh://$login@git.janware.com/srv/git/$fromuser/proj/$p
|
||||
|
|
@ -151,8 +163,8 @@ clone()
|
|||
run_git -C $p branch --set-upstream-to origin/master master
|
||||
# set +x
|
||||
fi
|
||||
run_git -C $p submodule update --init --recursive || fatal git submodule update failed in $p
|
||||
fi
|
||||
run_git -C $p submodule update --init --recursive || fatal git submodule update failed in $p
|
||||
done
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue