ulib/vcs: corriger le code de git_track_branch. Utiliser ce code dans pdev --sync
This commit is contained in:
parent
fc75fcd960
commit
01b9a6804f
11
lib/ulib/vcs
11
lib/ulib/vcs
|
@ -673,9 +673,8 @@ function git_track_branch() {
|
|||
[ -n "$branch" ] || return
|
||||
git_have_remote "$origin" || return
|
||||
[ "$(git config --get branch.$branch.remote)" == "$origin" ] && return
|
||||
if ! git_have_rbranch "$branch" "$origin"; then
|
||||
git push "$origin" "$branch" || return
|
||||
fi
|
||||
if git_have_rbranch "$branch" "$origin"; then
|
||||
if git_have_branch "$branch"; then
|
||||
local version="$(LANG=C git version)"
|
||||
version="${version#git version }"
|
||||
eval "version=(${version//./ })"
|
||||
|
@ -684,6 +683,12 @@ function git_track_branch() {
|
|||
else
|
||||
git branch -u "$origin/$branch" "$branch"
|
||||
fi
|
||||
else
|
||||
git branch -t "$branch" "$origin/$branch"
|
||||
fi
|
||||
elif git_have_branch "$branch"; then
|
||||
git push -u "$origin" "$branch" || return
|
||||
fi
|
||||
}
|
||||
function git_ensure_branch() {
|
||||
# retourner 0 si la branche a été créée, 1 si elle existait déjà, 2 en cas d'erreur
|
||||
|
|
12
pdev
12
pdev
|
@ -135,14 +135,13 @@ git_ensure_gitvcs
|
|||
|
||||
if [ "$action" == sync ]; then
|
||||
[ -z "$UTOOLS_VCS_OFFLINE" ] || die "L'option --sync nécessite le mode --online"
|
||||
version="$(LANG=C git version)"
|
||||
version="${version#git version }"
|
||||
eval "version=(${version//./ })"
|
||||
|
||||
setx -a branches=list_feature_branches "$origin"
|
||||
for branch in "${branches[@]}"; do
|
||||
if git_have_branch "$branch"; then
|
||||
git_track_branch "$branch" "$origin"
|
||||
else
|
||||
git branch -t "$branch" "$origin/$branch"
|
||||
fi
|
||||
done
|
||||
|
||||
exit $?
|
||||
|
@ -177,9 +176,7 @@ if [ "$action" == branch ]; then
|
|||
|
||||
# On est peut-être déjà sur la bonne branche
|
||||
if git_is_branch "$feature"; then
|
||||
if [ -z "$UTOOLS_VCS_OFFLINE" ]; then
|
||||
git_track_branch "$feature" "$origin"
|
||||
fi
|
||||
[ -z "$UTOOLS_VCS_OFFLINE" ] && git_track_branch "$feature" "$origin"
|
||||
git_fast_forward "$feature" "" "$origin"
|
||||
exit 0
|
||||
fi
|
||||
|
@ -202,6 +199,7 @@ Vous allez créer la nouvelle feature branch ${COULEUR_VERTE}$feature${COULEUR_N
|
|||
[ $? -eq 2 ] && die "Impossible de créer la branche $feature. Veuillez vérifier que la branche $source existe"
|
||||
git checkout "$feature" || r=$?
|
||||
fi
|
||||
[ -z "$UTOOLS_VCS_OFFLINE" ] && git_track_branch "$feature" "$origin"
|
||||
if [ "$r" -eq 0 ]; then
|
||||
# éventuellement fast-forwarder automatiquement
|
||||
git_fast_forward "$feature" "" "$origin"
|
||||
|
|
Loading…
Reference in New Issue