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,29 +179,22 @@ cmd_clone()
|
||||||
local pushurl=$remote_base/$login$remote_subpath/$project_name
|
local pushurl=$remote_base/$login$remote_subpath/$project_name
|
||||||
local curref=""
|
local curref=""
|
||||||
fat_marker "Fetching project $project_name from user $fromuser"
|
fat_marker "Fetching project $project_name from user $fromuser"
|
||||||
if [ "$fromuser" = "$login" ]; then
|
local remotename="jw-$fromuser"
|
||||||
if [ -d $project_dir ]; then
|
[ "$fromuser" = "$login" ] && remotename="origin"
|
||||||
run_git -C $project_dir pull --recurse-submodules=on-demand
|
if [ -d $project_dir ]; then
|
||||||
run_git -C $project_dir submodule foreach --recursive 'git fetch --tags -f origin'
|
run_git -C $project_dir remote | grep -q "^$remotename$" || {
|
||||||
else
|
run_git -C $project_dir remote add $remotename $pullurl
|
||||||
run_clone $remote_base/$fromuser$remote_subpath/$project_name $project_dir
|
[ "$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'
|
||||||
|
if [ "$toref" ]; then
|
||||||
|
run_git -C $project_dir rebase --autostash $remotename/$fromref $toref
|
||||||
|
run_git -C $project_dir merge --ff-only $remotename/$fromref $toref
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
local remotename="jw-$fromuser"
|
run_clone $remote_base/$fromuser$remote_subpath/$project_name $project_dir
|
||||||
if [ -d $project_dir ]; then
|
if [ "$fromuser" != "$login" ]; 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
|
|
||||||
}
|
|
||||||
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'
|
|
||||||
if [ "$toref" ]; then
|
|
||||||
run_git -C $project_dir rebase --autostash $remotename/$fromref $toref
|
|
||||||
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
|
|
||||||
run_git -C $project_dir remote rename origin $remotename || fatal "Failed to rename remote in $project_dir"
|
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
|
run_git -C $project_dir remote set-url --push $remotename no_push
|
||||||
if [ $create_remote_user_repos = true ]; then
|
if [ $create_remote_user_repos = true ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue