modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-10-20 12:15:39 +04:00
parent e99716735c
commit 8e347bc23e
7 changed files with 81 additions and 123 deletions

View File

@ -1,7 +1,5 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
## configuration par défaut
UPSTREAM=
DEVELOP=develop
FEATURE=wip/

View File

@ -128,12 +128,7 @@ function should_delete_merged() {
* PmanMergeDest -- nom effectif de la branche destination si elle est
définie dans .pman.conf
* IfMergeDest -- nom effectif de la branche source *si elle existe*, vide
sinon
* PMAN_CAN_MERGE -- indique si la fusion est théoriquement possible, c'est à
dire que $PMAN_MERGE_SRC et $PMAN_MERGE_DEST sont tous les deux non vides
* IfCanMerge -- indique si la fusion est effectivement possible, c'est à dire
que $IfMergeSrc et $IfMergeDest sont tous les deux non vides"
sinon"
[ -n "$PMAN_TOOL" ] || PMAN_TOOL="$MYNAME"
PMAN_REF_BRANCH="PMAN_TOOL_${PMAN_TOOL^^}"; PMAN_REF_BRANCH="${!PMAN_REF_BRANCH}"
@ -167,7 +162,6 @@ function set_pman_vars() {
;;
esac
[ -n "$PMAN_MERGE_SRC" -a -n "$PMAN_MERGE_DEST" ] && PMAN_CAN_MERGE=1 || PMAN_CAN_MERGE=
[ -n "$PMAN_MERGE_SRC" ] && PmanMergeSrc="${!PMAN_MERGE_SRC}" || PmanMergeSrc=
[ -n "$PMAN_MERGE_DEST" ] && PmanMergeDest="${!PMAN_MERGE_DEST}" || PmanMergeDest=
}

View File

@ -4,35 +4,11 @@ git_cleancheckout_DIRTY="\
Vous avez des modifications locales.
Enregistrez ces modifications avant de fusionner la branche"
function resolve_unique_branch() {
if [ "$PMAN_REF_BRANCH" == FEATURE ]; then
if [ $# -gt 0 ]; then
UniqueBranch="$FEATURE${1#$FEATURE}"
elif [[ "$CurrentBranch" == "$FEATURE"* ]]; then
UniqueBranch="$CurrentBranch"
elif [ ${#FeatureBranches[*]} -eq 0 ]; then
die "Vous devez spécifier la branche de feature"
elif [ ${#FeatureBranches[*]} -eq 1 ]; then
UniqueBranch="${FeatureBranches[0]}"
else
simple_menu \
UniqueBranch FeatureBranches \
-t "Branches de feature" \
-m "Veuillez choisir la branche de feature" \
-d "${FeatureBranches[0]}"
fi
PMAN_REF_BRANCH=UniqueBranch
PMAN_MERGE_SRC=UniqueBranch
else
die "resolve_unique_branch: $PMAN_REF_BRANCH: non implémenté"
fi
}
function dump_action() {
enote "Valeurs des variables:
PMAN_TOOL=$PMAN_TOOL
PMAN_REF_BRANCH=$PMAN_REF_BRANCH${PmanRefBranch:+ PmanRefBranch=$PmanRefBranch IfRefBranch=$IfRefBranch}
PMAN_BASE_BRANCH=$PMAN_BASE_BRANCH${PmanBaseBranch:+ PmanBaseBranch=$PmanBaseBranch IfCreateBase=$IfCreateBase}
PMAN_BASE_BRANCH=$PMAN_BASE_BRANCH${PmanBaseBranch:+ PmanBaseBranch=$PmanBaseBranch IfBaseBranch=$IfBaseBranch}
PMAN_MERGE_FROM=$PMAN_MERGE_FROM
PMAN_MERGE_TO=$PMAN_MERGE_TO
PMAN_DIR=$PMAN_DIR
@ -40,7 +16,6 @@ PMAN_PREL_MERGE=$PMAN_PREL_MERGE
PMAN_DELETE_MERGED=$PMAN_DELETE_MERGED
PMAN_MERGE_SRC=$PMAN_MERGE_SRC${PmanMergeSrc:+ PmanMergeSrc=$PmanMergeSrc IfMergeSrc=$IfMergeSrc}
PMAN_MERGE_DEST=$PMAN_MERGE_DEST${PmanMergeDest:+ PmanMergeDest=$PmanMergeDest IfMergeDest=$IfMergeDest}
PMAN_CAN_MERGE=$PMAN_CAN_MERGE IfCanMerge=$IfCanMerge
CurrentBranch=$CurrentBranch
LocalBranches=${LocalBranches[*]}
@ -57,7 +32,34 @@ DistBranch=$DistBranch
"
}
function _ensure_branch() {
function resolve_unique_branch() {
if [ "$PMAN_REF_BRANCH" == FEATURE ]; then
if [ $# -gt 0 ]; then
PmanRefBranch="$FEATURE${1#$FEATURE}"
elif [[ "$CurrentBranch" == "$FEATURE"* ]]; then
PmanRefBranch="$CurrentBranch"
elif [ ${#FeatureBranches[*]} -eq 0 ]; then
die "Vous devez spécifier la branche de feature"
elif [ ${#FeatureBranches[*]} -eq 1 ]; then
PmanRefBranch="${FeatureBranches[0]}"
else
simple_menu \
PmanRefBranch FeatureBranches \
-t "Branches de feature" \
-m "Veuillez choisir la branche de feature" \
-d "${FeatureBranches[0]}"
fi
else
die "resolve_unique_branch: $PMAN_REF_BRANCH: non implémenté"
fi
if [ "$PMAN_DIR" == to ]; then
PmanMergeSrc="$PmanRefBranch"
elif [ "$PMAN_DIR" == from ]; then
PmanMergeDest="$PmanRefBranch"
fi
}
function _ensure_ref_branch() {
[ -n "$PmanRefBranch" ] || die "\
La branche $PMAN_REF_BRANCH n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
@ -65,88 +67,71 @@ Veuillez éditer le fichier .pman.conf"
}
function _ensure_base_branch() {
[ -n "${!PMAN_BASE_BRANCH}" ] || die "\
[ -n "$PmanBaseBranch" ] || die "\
La branche $PMAN_BASE_BRANCH n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ "$1" == init -o -n "$IfCreateBase" ] || die "${!PMAN_BASE_BRANCH}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
}
function _ensure_merge_src() {
[ -n "$PmanMergeSrc" ] || die "\
La branche $PMAN_MERGE_SRC n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ "$1" == init -o -n "$IfMergeSrc" ] || die "$PmanMergeSrc: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
}
function _ensure_merge_dest() {
[ -n "$PmanMergeDest" ] || die "\
La branche $PMAN_MERGE_DEST n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ "$1" == init -o -n "$IfMergeDest" ] || die "$PmanMergeDest: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
[ "$1" == init -o -n "$IfBaseBranch" ] || die "$PmanBaseBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
}
function checkout_action() {
local -a push_branches
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
_ensure_branch init
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@"
_ensure_ref_branch init
if [ -n "$IfRefBranch" ]; then
git checkout "$IfRefBranch"
elif array_contains LocalBranches "$PmanRefBranch"; then
#if [ -n "$IfRefBranch" ]; then
# git checkout "$IfRefBranch"
#el
if array_contains LocalBranches "$PmanRefBranch"; then
git checkout "$PmanRefBranch"
elif array_contains AllBranches "$PmanRefBranch"; then
enote "$PmanRefBranch: une branche du même nom existe dans l'origine"
ask_yesno "Voulez-vous basculer sur cette branche?" O || die
git checkout "$PmanRefBranch"
elif [ -n "$PMAN_BASE_BRANCH" ]; then
else
_ensure_base_branch
resolve_should_push
local SrcBranch="${!PMAN_BASE_BRANCH}" DestBranch="$PmanRefBranch"
enote "Vous allez créer la branche ${COULEUR_BLEUE}$DestBranch${COULEUR_NORMALE} <-- ${COULEUR_ROUGE}$SrcBranch${COULEUR_NORMALE}"
enote "Vous allez créer la branche ${COULEUR_BLEUE}$PmanRefBranch${COULEUR_NORMALE} <-- ${COULEUR_ROUGE}$PmanBaseBranch${COULEUR_NORMALE}"
ask_yesno "Voulez-vous continuer?" O || die
einfo "Création de la branche $DestBranch"
git checkout -b "$DestBranch" "$SrcBranch" || die
push_branches+=("$DestBranch")
einfo "Création de la branche $PmanRefBranch"
git checkout -b "$PmanRefBranch" "$PmanBaseBranch" || die
push_branches+=("$PmanRefBranch")
_push_branches
fi
}
#XXXX
#[ -n "$PmanMergeSrc" ] ||
# die "Aucune branche définie pour $PMAN_MERGE_SRC. Veuillez éditer le fichier .pman.conf"
function ensure_merge_branches() {
[ -n "$PMAN_CAN_MERGE" ] ||
die "$PmanRefBranch: Aucune configuration de fusion trouvée pour cette branche"
[ -n "$PmanMergeSrc" ] || die "\
$PmanRefBranch: configuration de fusion non trouvée: la branche $PMAN_MERGE_SRC n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ -n "$PmanMergeDest" ] || die "\
$PmanRefBranch: configuration de fusion non trouvée: la branche $PMAN_MERGE_DEST n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
local branches
[ "$1" == -a ] && branches=AllBranches || branches=LocalBranches
SrcBranch="$PmanMergeSrc"
array_contains "$branches" "$SrcBranch" || die "$SrcBranch: branche source introuvable"
DestBranch="$PmanMergeDest"
array_contains "$branches" "$DestBranch" || die "$DestBranch: branche destination introuvable"
array_contains "$branches" "$PmanMergeSrc" || die "$PmanMergeSrc: branche source introuvable"
array_contains "$branches" "$PmanMergeDest" || die "$PmanMergeDest: branche destination introuvable"
}
function _show_action() {
local commits
setx commits=_list_commits
setx commits=_list_commits "$PmanMergeSrc" "$PmanMergeDest"
if [ -n "$commits" ]; then
if [ $ShowLevel -ge 2 ]; then
{
echo "\
# Commits à fusionner $SrcBranch --> $DestBranch
# Commits à fusionner $PmanMergeSrc --> $PmanMergeDest
$commits
"
_sd_COLOR=always _show_diff
} | less -eRF
else
einfo "Commits à fusionner $SrcBranch --> $DestBranch"
einfo "Commits à fusionner $PmanMergeSrc --> $PmanMergeDest"
eecho "$commits"
fi
fi
@ -154,6 +139,7 @@ $commits
function show_action() {
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@"
ensure_merge_branches
_show_action "$@"
}
@ -161,7 +147,7 @@ function show_action() {
function _merge_action() {
enote "\
Ce script va
- fusionner la branche ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE} dans ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}${Push:+
- fusionner la branche ${COULEUR_BLEUE}$PmanMergeSrc${COULEUR_NORMALE} dans ${COULEUR_ROUGE}$PmanMergeDest${COULEUR_NORMALE}${Push:+
- pousser les branches modifiées}"
ask_yesno "Voulez-vous continuer?" O || die
@ -269,31 +255,35 @@ Il y a aussi les commandes supplémentaires suivantes:
}
function merge_action() {
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@"
ensure_merge_branches -a
if [ -n "$PMAN_PREL_MERGE" ]; then
[ -n "$ForceMerge" ] || die "$SrcBranch: cette branche doit être fusionnée dans $DestBranch avec prel"
[ -n "$ForceMerge" ] || die "$PmanMergeSrc: cette branche doit être fusionnée dans $PmanMergeDest avec prel"
fi
if [ -n "$PMAN_DELETE_MERGED" ]; then
ShouldDelete=1
[ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$PmanMergeDest"
else
ShouldDelete=
Delete=
[ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$PmanMergeSrc"
fi
[ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$SrcBranch"
[ -n "$PMAN_DELETE_MERGED" ] || Delete=
[ -z "$_Fake" ] && git_ensure_cleancheckout
if ! array_contains LocalBranches "$SrcBranch" && array_contains AllBranches "$SrcBranch"; then
enote "$SrcBranch: une branche du même nom existe dans l'origine"
if ! array_contains LocalBranches "$PmanMergeSrc" && array_contains AllBranches "$PmanMergeSrc"; then
enote "$PmanMergeSrc: une branche du même nom existe dans l'origine"
fi
if ! array_contains LocalBranches "$DestBranch" && array_contains AllBranches "$DestBranch"; then
enote "$DestBranch: une branche du même nom existe dans l'origine"
if ! array_contains LocalBranches "$PmanMergeDest" && array_contains AllBranches "$PmanMergeDest"; then
enote "$PmanMergeDest: une branche du même nom existe dans l'origine"
fi
array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche locale introuvable"
array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche locale introuvable"
array_contains LocalBranches "$PmanMergeSrc" || die "$PmanMergeSrc: branche locale introuvable"
array_contains LocalBranches "$PmanMergeDest" || die "$PmanMergeDest: branche locale introuvable"
resolve_should_push
set -x #XXX
_merge_action "$@"
}
function rebase_action() {
die "non implémenté"
}

View File

@ -1,9 +1,5 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
## configuration de la branche 7.4 d'un projet PHP multiversion
# il s'agit d'un projet avec deux branches parallèles: 7.4 et 8.2, les
# modifications de la 7.4 étant incluses dans la branche 8.2
UPSTREAM=
DEVELOP=dev74
FEATURE=wip74/

View File

@ -1,9 +1,5 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
## configuration de la branche 8.2 d'un projet PHP multiversion
# il s'agit d'un projet avec deux branches parallèles: 7.4 et 8.2, les
# modifications de la 7.4 étant incluses dans la branche 8.2
UPSTREAM=dev74
DEVELOP=dev82
FEATURE=wip82/

View File

@ -8,13 +8,8 @@ if check_gitdir; then
load_branches all
load_config
set_pman_vars
if [ -n "$PmanMergeSrc" ]; then
load_branches current "$PmanMergeSrc"
loaded_config=1
elif [ -n "$PmanRefBranch" ]; then
load_branches current "$PmanRefBranch"
loaded_config=1
fi
load_branches current
loaded_config=1
else
set_pman_vars
fi
@ -78,23 +73,15 @@ c'est l'option par défaut"
)
fi
if [ -n "$PMAN_CAN_MERGE" ]; then
if [ -n "$PMAN_MERGE_SRC" -a -n "$PMAN_MERGE_DEST" ]; then
if [ -n "$PMAN_UNIQUE" ]; then
usage="${usage}|--show|--merge"
else
usage="${usage} $PMAN_REF_BRANCH
--show|--merge"
fi
if [ "$PMAN_REF_BRANCH" != "$PMAN_MERGE_SRC" ]; then
usage="$usage
NB: du fait de la configuration des branches, la fusion se fait dans le sens
inverse $MergeSrcDesc --> $MergeDestDesc"
else
usage="$usage
NB: La fusion se fait dans le sens $MergeSrcDesc --> $MergeDestDesc"
fi
[ "$PMAN_REF_BRANCH" != "$PMAN_MERGE_SRC" ] && bewareDir="
NB: la fusion se fait dans le sens inverse" || bewareDir=
variables="\
Les variables supplémentaires suivantes peuvent être définies:
BEFORE_MERGE_${PMAN_MERGE_SRC}
@ -106,7 +93,7 @@ lister ce qui serait fusionné dans la branche $MergeDestDesc"
#lancer git rebase -i sur la branche $MergeSrcDesc. cela permet de réordonner
#les commits pour nettoyer l'historique avant la fusion"
-m,--merge action=merge "\
fusionner la branche $MergeSrcDesc dans la branche $MergeDestDesc"
fusionner la branche $MergeSrcDesc dans la branche $MergeDestDesc$bewareDir"
--tech-merge TechMerge=1 "++option non documentée"
-s:,--squash:COMMIT_MSG SquashMsg= "\
fusionner les modifications de la branche comme un seul commit"
@ -180,11 +167,7 @@ if [ -z "$loaded_config" -o -n "$chdir" -o -n "$ConfigFile" -o -n "$ConfigBranch
load_branches all
load_config
set_pman_vars
if [ -n "$PmanMergeSrc" ]; then
load_branches current "$PmanMergeSrc"
elif [ -n "$PmanRefBranch" ]; then
load_branches current "$PmanRefBranch"
fi
load_branches current
fi
resolve_should_push quiet

View File

@ -170,7 +170,8 @@ ne pas pousser les branches vers leur origine après leur création"
pousser les branches vers leur origine après leur création.
c'est l'option par défaut"
-f,--force-create ForceCreate=1 "\
Avec config, forcer la (re)création du fichier .pman.conf"
Forcer la (re)création des fichiers de configuration (notamment .pman.conf,
.composer.pman.yml, etc.)"
)
parse_args "$@"; set -- "${args[@]}"