mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
pgit.sh clone: Merge code path "from-user == login"
The cases from-user == login and from-user != login have different code paths and can be streamlined somewhat, so do that. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
01bf027070
commit
f38abb9057
1 changed files with 14 additions and 21 deletions
|
|
@ -179,19 +179,12 @@ cmd_clone()
|
|||
local pushurl=$remote_base/$login$remote_subpath/$project_name
|
||||
local curref=""
|
||||
fat_marker "Fetching project $project_name from user $fromuser"
|
||||
if [ "$fromuser" = "$login" ]; then
|
||||
if [ -d $project_dir ]; then
|
||||
run_git -C $project_dir pull --recurse-submodules=on-demand
|
||||
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
|
||||
else
|
||||
run_clone $remote_base/$fromuser$remote_subpath/$project_name $project_dir
|
||||
fi
|
||||
else
|
||||
local remotename="jw-$fromuser"
|
||||
[ "$fromuser" = "$login" ] && remotename="origin"
|
||||
if [ -d $project_dir ]; then
|
||||
run_git -C $project_dir remote | grep -q "^$remotename$" || {
|
||||
run_git -C $project_dir remote add $remotename $pullurl
|
||||
run_git -C $project_dir remote set-url --push $remotename no_push
|
||||
[ "$fromuser" = "$login" ] || run_git -C $project_dir remote set-url --push $remotename no_push
|
||||
}
|
||||
run_git -C $project_dir fetch --prune --recurse-submodules=on-demand $remotename $fromref
|
||||
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
|
||||
|
|
@ -200,8 +193,8 @@ cmd_clone()
|
|||
run_git -C $project_dir merge --ff-only $remotename/$fromref $toref
|
||||
fi
|
||||
else
|
||||
# set -x
|
||||
run_clone $remote_base/$fromuser$remote_subpath/$project_name $project_dir
|
||||
if [ "$fromuser" != "$login" ]; then
|
||||
run_git -C $project_dir remote rename origin $remotename || fatal "Failed to rename remote in $project_dir"
|
||||
run_git -C $project_dir remote set-url --push $remotename no_push
|
||||
if [ $create_remote_user_repos = true ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue