migration prel

This commit is contained in:
Jephté Clain 2025-10-20 20:55:35 +04:00
parent a732d22d92
commit bf4d934daa
3 changed files with 203 additions and 261 deletions

View File

@ -36,11 +36,11 @@ PMAN_TOOL_PDEV=DEVELOP
PMAN_TOOL_PWIP=FEATURE
PMAN_TOOL_PMAIN=MAIN
PMAN_TOOL_PDIST=DIST
UPSTREAM_BASE= ; UPSTREAM_MERGE_FROM= ; UPSTREAM_MERGE_TO=DEVELOP ; UPSTREAM_PREL= ; UPSTREAM_DELETE=
DEVELOP_BASE=MAIN ; DEVELOP_MERGE_FROM=FEATURE ; DEVELOP_MERGE_TO=MAIN ; DEVELOP_PREL=to ; DEVELOP_DELETE=from
MAIN_BASE= ; MAIN_MERGE_FROM=DEVELOP ; MAIN_MERGE_TO=DIST ; MAIN_PREL=from ; MAIN_DELETE=
DIST_BASE=MAIN ; DIST_MERGE_FROM=MAIN ; DIST_MERGE_TO= ; DIST_PREL= ; DIST_DELETE=
FEATURE_BASE=DEVELOP ; FEATURE_MERGE_FROM= ; FEATURE_MERGE_TO=DEVELOP ; FEATURE_PREL= ; FEATURE_DELETE=to
UPSTREAM_BASE= ; UPSTREAM_MERGE_FROM= ; UPSTREAM_MERGE_TO=DEVELOP ; UPSTREAM_PREL= ; UPSTREAM_DELETE=
DEVELOP_BASE=MAIN ; DEVELOP_MERGE_FROM=FEATURE ; DEVELOP_MERGE_TO=MAIN ; DEVELOP_PREL=from ; DEVELOP_DELETE=to
MAIN_BASE= ; MAIN_MERGE_FROM=DEVELOP ; MAIN_MERGE_TO=DIST ; MAIN_PREL=to ; MAIN_DELETE=
DIST_BASE=MAIN ; DIST_MERGE_FROM=MAIN ; DIST_MERGE_TO= ; DIST_PREL= ; DIST_DELETE=
FEATURE_BASE=DEVELOP ; FEATURE_MERGE_FROM= ; FEATURE_MERGE_TO=DEVELOP ; FEATURE_PREL= ; FEATURE_DELETE=from
function get_base_branch() {
# afficher la branche depuis laquelle créer la branche $1
@ -112,8 +112,8 @@ function should_delete_merged() {
* PMAN_MERGE_TO -- code de la branche destination dans laquelle la fusion est
faite depuis PMAN_REF_BRANCH. vide si la branche n'a pas de destination
* PMAN_DIR -- direction de la fusion:
'from' si on fait PMAN_MERGE_FROM --> PMAN_REF_BRANCH
'to' si on fait PMAN_REF_BRANCH --> PMAN_MERGE_TO
'from' si on fait PMAN_REF_BRANCH --> PMAN_MERGE_TO
'to' si on fait PMAN_MERGE_FROM --> PMAN_REF_BRANCH
* PMAN_PREL_MERGE -- si la fusion devrait se faire avec prel
* PMAN_DELETE_MERGED -- s'il faut supprimer la branche source après la fusion
@ -144,18 +144,16 @@ function set_pman_vars() {
PMAN_MERGE_FROM=$(get_merge_from_branch "$PMAN_REF_BRANCH")
PMAN_MERGE_TO=$(get_merge_to_branch "$PMAN_REF_BRANCH")
if [ -n "$1" ]; then PMAN_DIR="$1"
else PMAN_DIR=to
#elif [ -n "$PMAN_MERGE_TO" ]; then PMAN_DIR=to
#else PMAN_DIR=from
else PMAN_DIR=from
fi
PMAN_PREL_MERGE=$(should_prel_merge "$PMAN_REF_BRANCH" "$PMAN_DIR" && echo 1)
PMAN_DELETE_MERGED=$(should_delete_merged "$PMAN_REF_BRANCH" "$PMAN_DIR" && echo 1)
case "$PMAN_DIR" in
to)
from)
PMAN_MERGE_SRC="$PMAN_REF_BRANCH"
PMAN_MERGE_DEST="$PMAN_MERGE_TO"
;;
from)
to)
PMAN_MERGE_SRC="$PMAN_MERGE_FROM"
PMAN_MERGE_DEST="$PMAN_REF_BRANCH"
;;
@ -216,7 +214,7 @@ $1 == "|" {
}
function _list_commits() {
local source="${1:-$SrcBranch}" dest="${2:-$DestBranch}" mergebase
local source="${1:-$PmanMergeSrc}" dest="${2:-$PmanMergeDest}" mergebase
setx mergebase=git merge-base "$dest" "$source"
git log --oneline --graph --no-decorate "$mergebase..$source" |
grep -vF '|\' | grep -vF '|/' | sed -r 's/^(\| )+\* +/| /; s/^\* +/+ /' |
@ -224,7 +222,7 @@ function _list_commits() {
}
function _show_diff() {
local source="${1:-$SrcBranch}" dest="${2:-$DestBranch}" mergebase
local source="${1:-$PmanMergeSrc}" dest="${2:-$PmanMergeDest}" mergebase
setx mergebase=git merge-base "$dest" "$source"
git diff ${_sd_COLOR:+--color=$_sd_COLOR} "$mergebase..$source"
}
@ -306,7 +304,7 @@ function ensure_gitdir() {
}
function load_branches() {
local what="${1:-all}"; shift
local branch what="${1:-all}"; shift
case "$what" in
all)
[ -n "$Origin" ] || Origin=origin
@ -316,30 +314,6 @@ function load_branches() {
setx -a AllBranches=git_list_pbranches "$Origin"
;;
current)
SrcBranch="$1"
[ -n "$SrcBranch" ] || SrcBranch="$CurrentBranch"
case "$SrcBranch" in
"$UPSTREAM") SrcType=upstream; DestBranch="$DEVELOP";;
"$FEATURE"*) SrcType=feature; DestBranch="$DEVELOP";;
"$DEVELOP") SrcType=develop; DestBranch="$MAIN";;
"$RELEASE"*) SrcType=release; DestBranch="$MAIN";;
"$HOTFIX"*) SrcType=hotfix; DestBranch="$MAIN";;
"$MAIN") SrcType=main; DestBranch="$DIST";;
"$DIST") SrcType=dist; DestBranch=;;
*) SrcType=; DestBranch=;;
esac
case "$DestBranch" in
"$UPSTREAM") DestType=upstream;;
"$FEATURE"*) DestType=feature;;
"$DEVELOP") DestType=develop;;
"$RELEASE"*) DestType=release;;
"$HOTFIX"*) DestType=hotfix;;
"$MAIN") DestType=main;;
"$DIST") DestType=dist;;
*) DestType=;;
esac
local branch
UpstreamBranch=
FeatureBranches=()
DevelopBranch=
@ -469,10 +443,8 @@ function _mscript_start() {
#!/bin/bash
$(qvals source "$NULIBDIR/load.sh") || exit 1
$(echo_setv SrcBranch="$SrcBranch")
$(echo_setv SrcType="$SrcType")
$(echo_setv DestBranch="$DestBranch")
$(echo_setv DestType="$DestType")
$(echo_setv SrcBranch="$PmanMergeSrc")
$(echo_setv DestBranch="$PmanMergeDest")
merge=
delete=
@ -492,32 +464,32 @@ function _mscript_merge_branch() {
local msg
# basculer sur la branche
_scripta "switch to branch $DestBranch" <<EOF
$comment$(qvals git checkout "$DestBranch")$or_die
_scripta "switch to branch $PmanMergeDest" <<EOF
$comment$(qvals git checkout "$PmanMergeDest")$or_die
EOF
if [ -n "$SquashMsg" ]; then
msg="$SquashMsg"
[ -n "$TechMerge" ] && msg="<pman>$msg"
_scripta "squash merge $SrcBranch" <<EOF
$comment$(qvals git merge "$SrcBranch" --squash)$or_die
_scripta "squash merge $PmanMergeSrc" <<EOF
$comment$(qvals git merge "$PmanMergeSrc" --squash)$or_die
$comment$(qvals git commit -m "$msg")$or_die
EOF
else
msg="Intégration de la branche $SrcBranch"
msg="Intégration de la branche $PmanMergeSrc"
[ -n "$TechMerge" ] && msg="<pman>$msg"
_scripta "merge $SrcBranch" <<EOF
$comment$(qvals git merge "$SrcBranch" --no-ff -m "$msg")$or_die
_scripta "merge $PmanMergeSrc" <<EOF
$comment$(qvals git merge "$PmanMergeSrc" --no-ff -m "$msg")$or_die
EOF
fi
array_addu push_branches "$DestBranch"
array_addu push_branches "$PmanMergeDest"
}
function _mscript_delete_branch() {
_scripta "delete branch $SrcBranch" <<EOF
$comment$(qvals git branch -D "$SrcBranch")$or_die
_scripta "delete branch $PmanMergeSrc" <<EOF
$comment$(qvals git branch -D "$PmanMergeSrc")$or_die
EOF
array_addu delete_branches ":$SrcBranch"
array_addu delete_branches ":$PmanMergeSrc"
}
################################################################################
@ -529,13 +501,11 @@ function _rscript_start() {
#!/bin/bash
$(qvals source "$NULIBDIR/load.sh") || exit 1
$(echo_setv SrcBranch="$SrcBranch")
$(echo_setv SrcType="$SrcType")
$(echo_setv SrcBranch="$PmanMergeSrc")
$(echo_setv Version="$Version")
$(echo_setv Tag="$Tag")
$(echo_setv ReleaseBranch="$ReleaseBranch")
$(echo_setv DestBranch="$DestBranch")
$(echo_setv DestType="$DestType")
$(echo_setv DestBranch="$PmanMergeDest")
create=
merge=
@ -564,7 +534,7 @@ function _rscript_create_release_branch() {
# créer la branche de release et basculer dessus
_scripta "create branch $ReleaseBranch" <<EOF
$(qvals git checkout -b "$ReleaseBranch" "$SrcBranch")$or_die
$(qvals git checkout -b "$ReleaseBranch" "$PmanMergeSrc")$or_die
EOF
# créer le changelog
@ -624,3 +594,146 @@ function _rscript_delete_release_branch() {
$comment$(qvals git branch -D "$ReleaseBranch")$or_die
EOF
}
################################################################################
# Outils
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 IfBaseBranch=$IfBaseBranch}
PMAN_MERGE_FROM=$PMAN_MERGE_FROM
PMAN_MERGE_TO=$PMAN_MERGE_TO
PMAN_DIR=$PMAN_DIR
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}
CurrentBranch=$CurrentBranch
LocalBranches=${LocalBranches[*]}
RemoteBranches=${RemoteBranches[*]}
AllBranches=${AllBranches[*]}
UpstreamBranch=$UpstreamBranch
FeatureBranches=${FeatureBranches[*]}
DevelopBranch=$DevelopBranch
ReleaseBranch=$ReleaseBranch
HotfixBranch=$HotfixBranch
MainBranch=$MainBranch
DistBranch=$DistBranch
"
}
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" == from ]; then
PmanMergeSrc="$PmanRefBranch"
elif [ "$PMAN_DIR" == to ]; 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"
[ "$1" == init -o -n "$IfRefBranch" ] || die "$PmanRefBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
}
function _ensure_base_branch() {
[ -n "$PmanBaseBranch" ] || die "\
La branche $PMAN_BASE_BRANCH n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ "$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 "$@"
_ensure_ref_branch init
#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"
else
_ensure_base_branch
resolve_should_push
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 $PmanRefBranch"
git checkout -b "$PmanRefBranch" "$PmanBaseBranch" || die
push_branches+=("$PmanRefBranch")
_push_branches
fi
}
function ensure_merge_branches() {
[ -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
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 "$PmanMergeSrc" "$PmanMergeDest"
if [ -n "$commits" ]; then
if [ $ShowLevel -ge 2 ]; then
{
echo "\
# Commits à fusionner $PmanMergeSrc --> $PmanMergeDest
$commits
"
_sd_COLOR=always _show_diff
} | less -eRF
else
einfo "Commits à fusionner $PmanMergeSrc --> $PmanMergeDest"
eecho "$commits"
fi
fi
}
function show_action() {
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@"
ensure_merge_branches
_show_action "$@"
}

View File

@ -7,33 +7,7 @@ git_cleancheckout_DIRTY="\
Vous avez des modifications locales.
Enregistrez ces modifications avant de créer une release"
function show_action() {
local commits
setx commits=_list_commits
if [ -n "$commits" ]; then
if [ $ShowLevel -ge 2 ]; then
{
echo "\
# Commits à fusionner $SrcBranch --> $DestBranch
$commits
"
_sd_COLOR=always _show_diff
} | less -eRF
else
einfo "Commits à fusionner $SrcBranch --> $DestBranch"
eecho "$commits"
fi
fi
}
function ensure_branches() {
[ -n "$SrcBranch" -a -n "$DestBranch" ] ||
die "$SrcBranch: Aucune configuration de fusion trouvée pour cette branche"
array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche source introuvable"
array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche destination introuvable"
function ensure_rel_infos() {
Tag="$TAG_PREFIX$Version$TAG_SUFFIX"
local -a tags
setx -a tags=git tag -l "${TAG_PREFIX}*${TAG_SUFFIX}"
@ -71,14 +45,14 @@ L'option --no-push a été forcée puisque ce dépôt n'a pas d'origine"
if [ -n "$Merge" ]; then
enote "\
Ce script va:
- créer la branche de release ${COULEUR_VERTE}$ReleaseBranch${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE}
- créer la branche de release ${COULEUR_VERTE}$ReleaseBranch${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$PmanMergeSrc${COULEUR_NORMALE}
- la provisionner avec une description des changements
- la fusionner dans la branche destination ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}${Push:+
- la fusionner dans la branche destination ${COULEUR_ROUGE}$PmanMergeDest${COULEUR_NORMALE}${Push:+
- pousser les branches modifiées}"
else
enote "\
Ce script va:
- créer la branche de release ${COULEUR_VERTE}$ReleaseBranch${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE}
- créer la branche de release ${COULEUR_VERTE}$ReleaseBranch${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$PmanMergeSrc${COULEUR_NORMALE}
- la provisionner avec une description des changements
Vous devrez:
- mettre à jour les informations de release puis relancer ce script"
@ -123,8 +97,8 @@ EOF
$BEFORE_MERGE_RELEASE
)$or_die
EOF
_rscript_merge_release_branch "$DestBranch" "$Tag"
_rscript_merge_release_branch "$SrcBranch"
_rscript_merge_release_branch "$PmanMergeDest" "$Tag"
_rscript_merge_release_branch "$PmanMergeSrc"
_rscript_delete_release_branch
[ -n "$AFTER_MERGE_RELEASE" ] && _scripta <<EOF
(
@ -183,14 +157,14 @@ function merge_release_action() {
enote "\
Vous allez:
- fusionner la branche de release ${COULEUR_VERTE}$ReleaseBranch${COULEUR_NORMALE}
dans la branche destination ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}"
dans la branche destination ${COULEUR_ROUGE}$PmanMergeDest${COULEUR_NORMALE}"
ask_yesno "Voulez-vous continuer?" O || die
}
function merge_hotfix_action() {
enote "\
Vous allez intégrer la branche de hotfix ${COULEUR_JAUNE}$HotfixBranch${COULEUR_NORMALE}
dans la branche destination ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}"
dans la branche destination ${COULEUR_ROUGE}$PmanMergeDest${COULEUR_NORMALE}"
ask_yesno "Voulez-vous continuer?" O || die
}
@ -206,14 +180,14 @@ _Fake=
_KeepScript=
action=release
ShowLevel=0
[ -z "$PMAN_NO_MERGE" ] && Merge=1 || Merge=
[ -z "$PMAN_NO_PUSH" ] && Push=1 || Push=
Merge=1
Push=1
Version=
CurrentVersion=
ForceCreate=
args=(
"faire une nouvelle release à partir de la branche source"
" -v VERSION [source]
"faire une nouvelle release"
" -v VERSION
CONFIGURATION
Le fichier .pman.conf contient la configuration des branches. Les variables
@ -261,8 +235,10 @@ parse_args "$@"; set -- "${args[@]}"
# charger la configuration
ensure_gitdir "$chdir"
load_branches all
load_config "$MYNAME"
load_branches current "$1"; shift
load_config
PMAN_REF_BRANCH=DEVELOP
set_pman_vars
load_branches current
[ -n "$Merge" -a -n "$NOAUTO" ] && ManualRelease=1 || ManualRelease=
[ -n "$ManualRelease" ] && Merge=
@ -272,19 +248,12 @@ resolve_should_push quiet
# puis faire l'action que l'on nous demande
case "$action" in
show)
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
ensure_branches
show_action "$@"
;;
show) show_action "$@";;
release)
[ -z "$_Fake" ] && git_ensure_cleancheckout
ensure_branches
case "$SrcType" in
release) merge_release_action "$@";;
hotfix) merge_hotfix_action "$@";;
*) create_release_action "$@";;
esac
ensure_merge_branches
ensure_rel_infos
create_release_action "$@"
;;
*)
die "$action: action non implémentée"

162
bin/ptool
View File

@ -7,146 +7,6 @@ git_cleancheckout_DIRTY="\
Vous avez des modifications locales.
Enregistrez ces modifications avant de fusionner la branche"
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 IfBaseBranch=$IfBaseBranch}
PMAN_MERGE_FROM=$PMAN_MERGE_FROM
PMAN_MERGE_TO=$PMAN_MERGE_TO
PMAN_DIR=$PMAN_DIR
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}
CurrentBranch=$CurrentBranch
LocalBranches=${LocalBranches[*]}
RemoteBranches=${RemoteBranches[*]}
AllBranches=${AllBranches[*]}
UpstreamBranch=$UpstreamBranch
FeatureBranches=${FeatureBranches[*]}
DevelopBranch=$DevelopBranch
ReleaseBranch=$ReleaseBranch
HotfixBranch=$HotfixBranch
MainBranch=$MainBranch
DistBranch=$DistBranch
"
}
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"
[ "$1" == init -o -n "$IfRefBranch" ] || die "$PmanRefBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
}
function _ensure_base_branch() {
[ -n "$PmanBaseBranch" ] || die "\
La branche $PMAN_BASE_BRANCH n'a pas été définie.
Veuillez éditer le fichier .pman.conf"
[ "$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 "$@"
_ensure_ref_branch init
#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"
else
_ensure_base_branch
resolve_should_push
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 $PmanRefBranch"
git checkout -b "$PmanRefBranch" "$PmanBaseBranch" || die
push_branches+=("$PmanRefBranch")
_push_branches
fi
}
function ensure_merge_branches() {
[ -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
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 "$PmanMergeSrc" "$PmanMergeDest"
if [ -n "$commits" ]; then
if [ $ShowLevel -ge 2 ]; then
{
echo "\
# Commits à fusionner $PmanMergeSrc --> $PmanMergeDest
$commits
"
_sd_COLOR=always _show_diff
} | less -eRF
else
einfo "Commits à fusionner $PmanMergeSrc --> $PmanMergeDest"
eecho "$commits"
fi
fi
}
function show_action() {
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@"
ensure_merge_branches
_show_action "$@"
}
function _merge_action() {
enote "\
Ce script va
@ -304,10 +164,10 @@ USAGE
OPTIONS
REF
-t, --merge-to REF
-f, --merge-from REF
spécifier la branche de référence et indiquer que la fusion se fait dans
le sens REF --> DEST. DEST est calculé en fonction de REF
-f, --merge-from REF
-t, --merge-to REF
spécifier la branche de référence et indiquer que la fusion se fait dans
le sens SRC --> REF. SRC est calculé en fonction de REF"
fi
@ -317,14 +177,6 @@ OPTIONS
[ -n "$ref" ] || die "vous spécifier la branche de référence"
case "$ref" in
-t|--merge-to)
ref="$1"; shift
dir=to
;;
-t*)
ref="${ref#-t}"
dir=to
;;
-f|--merge-from)
ref="$1"; shift
dir=from
@ -333,6 +185,14 @@ OPTIONS
ref="${ref#-f}"
dir=from
;;
-t|--merge-to)
ref="$1"; shift
dir=to
;;
-t*)
ref="${ref#-t}"
dir=to
;;
esac
PMAN_TOOL=
PMAN_REF_BRANCH="${ref^^}"
@ -420,7 +280,7 @@ if [ -n "$PMAN_MERGE_SRC" -a -n "$PMAN_MERGE_DEST" ]; then
usage="${usage} $PMAN_REF_BRANCH
--show|--merge"
fi
[ "$PMAN_REF_BRANCH" != "$PMAN_MERGE_SRC" ] && bewareDir="
[ "$PMAN_REF_BRANCH" != "$PMAN_MERGE_DEST" ] && bewareDir="
NB: la fusion se fait dans le sens inverse" || bewareDir=
variables="\
Les variables supplémentaires suivantes peuvent être définies: