pu: support du scenario ou la branche de feature distante a été supprimée
This commit is contained in:
parent
151433b85c
commit
fec6b2fb8b
57
lib/ulib/vcs
57
lib/ulib/vcs
|
@ -456,11 +456,64 @@ function git_update() {
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local orig_branch restore_branch remote rbranch pbranch
|
local branch orig_branch restore_branch remote rbranch pbranch
|
||||||
local -a branches
|
local -a branches prbranches crbranches dbranches
|
||||||
|
|
||||||
|
array_from_lines prbranches "$(git_list_rbranches)"
|
||||||
git fetch -p "$@" || return
|
git fetch -p "$@" || return
|
||||||
|
array_from_lines crbranches "$(git_list_rbranches)"
|
||||||
|
|
||||||
|
# vérifier s'il n'y a pas des branches distantes qui ont été supprimées
|
||||||
|
for branch in "${prbranches[@]}"; do
|
||||||
|
if ! array_contains crbranches "$branch"; then
|
||||||
|
array_add dbranches "${branch#*/}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ${#dbranches[*]} -gt 0 ]; then
|
||||||
|
eimportant "One or more distant branches where deleted"
|
||||||
|
for branch in "${dbranches[@]}"; do
|
||||||
|
if git_have_branch "$branch"; then
|
||||||
|
if ! ask_yesno "Do you want to delete local branch $branch?" X; then
|
||||||
|
array_del dbranches "$branch"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ ${#dbranches[*]} -gt 0 ]; then
|
||||||
|
array_from_lines branches "$(git_list_branches)"
|
||||||
|
branch="$(git_get_branch)"
|
||||||
|
if array_contains dbranches "$branch"; then
|
||||||
|
# si la branche courante est l'une des branches à supprimer, il faut
|
||||||
|
# basculer vers develop ou master
|
||||||
|
local swto
|
||||||
|
if [ -z "$swto" ] && array_contains branches develop && ! array_contains dbranches develop; then
|
||||||
|
swto=develop
|
||||||
|
fi
|
||||||
|
if [ -z "$swto" ] && array_contains branches master && ! array_contains dbranches master; then
|
||||||
|
swto=master
|
||||||
|
fi
|
||||||
|
if ! git_check_cleancheckout; then
|
||||||
|
echo "* There are uncommitted local changes. However current branch is slated for removal.
|
||||||
|
Make your verifications then delete the local branches:
|
||||||
|
${swto:+$(qvals git checkout "$swto")
|
||||||
|
}$(qvals git branch -D "${dbranches[@]}")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ -n "$swto" ]; then
|
||||||
|
git checkout -q "$swto"
|
||||||
|
else
|
||||||
|
echo "* Current branch is slated for removal but I don't know to which branch I should switch first.
|
||||||
|
Make your choice then delete the local branches:
|
||||||
|
$(qvals git branch -D "${dbranches[@]}")"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
for branch in "${dbranches[@]}"; do
|
||||||
|
git branch -D "$branch"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# intégrer les modifications dans les branches locales
|
||||||
if ! git_check_cleancheckout; then
|
if ! git_check_cleancheckout; then
|
||||||
branch="$(git_get_branch)"
|
branch="$(git_get_branch)"
|
||||||
remote="$(git_get_branch_remote "$branch")"
|
remote="$(git_get_branch_remote "$branch")"
|
||||||
|
|
Loading…
Reference in New Issue