From 1b6afc3584f06b4ac231a2cbca3553df0d68294a Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 25 Feb 2025 12:20:16 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- wip/_rel | 338 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 238 insertions(+), 100 deletions(-) diff --git a/wip/_rel b/wip/_rel index 51d657b..321b36f 100755 --- a/wip/_rel +++ b/wip/_rel @@ -13,20 +13,38 @@ DEVELOP=develop FEATURE=wip/ RELEASE=release- MAIN=master +TAG_PREFIX= TAG_SUFFIX= HOTFIX=hotfix- DIST= NOAUTO= +function load_branches() { + setx CurrentBranch=git_get_branch + setx -a LocalBranches=git_list_branches + setx -a RemoteBranches=git_list_rbranches "$Origin" + setx -a AllBranches=git_list_pbranches "$Origin" +} + function load_config() { - [ -z "$Config" -a -f .pman.conf ] && Config=.pman.conf - if [ -n "$Config" ]; then - source "$Config" + if [ -n "$ConfigFile" ]; then + source "$ConfigFile" || die + elif [ -n "$ConfigBranch" ]; then + if ! array_contains LocalBranches "$ConfigBranch"; then + die "$ConfigBranch: branche de configuration introuvable" + else + local config="$(git show "$ConfigBranch:.pman.conf" 2>/dev/null)" + [ -n "$config" ] || die "$ConfigBranch: aucune configuration trouvée sur cette branche" + eval "$config" + fi + elif [ -f .pman.conf ]; then + ConfigFile=.pman.conf + source "$ConfigFile" else - source "$MYDIR/pman${MYNAME#_rel}.conf" + ConfigFile="$MYDIR/pman${MYNAME#_rel}.conf" + source "$ConfigFile" fi - setx CurrentBranch=git_get_branch SrcBranch="$1" [ -n "$SrcBranch" ] || SrcBranch="$CurrentBranch" case "$SrcBranch" in @@ -45,23 +63,33 @@ function ensure_branches() { [ -n "$SrcBranch" -a -n "$DestBranch" ] || die "$SrcBranch: Aucune configuration de fusion trouvée pour cette branche" - setx -a Branches=git_list_pbranches "$Origin" - array_contains Branches "$SrcBranch" || die "$SrcBranch: branche source introuvable" - array_contains Branches "$DestBranch" || die "$DestBranch: branche destination introuvable" + array_contains AllBranches "$SrcBranch" || die "$SrcBranch: branche source introuvable" + array_contains AllBranches "$DestBranch" || die "$DestBranch: branche destination introuvable" local branch ReleaseBranch= - for branch in "${Branches[@]}"; do + HotfixBranch= + for branch in "${AllBranches[@]}"; do if [[ "$branch" == "$RELEASE"* ]]; then ReleaseBranch="$branch" + elif [[ "$branch" == "$HOTFIX"* ]]; then + HotfixBranch="$branch" fi done } +################################################################################ +# Initialisation +################################################################################ + function init_action() { : } +################################################################################ +# Informations +################################################################################ + function _filter_rel() { # enlever les commits "techniques" générés par ce script grep -v "Intégration de la branche $RELEASE" | @@ -102,6 +130,27 @@ function _list_commits() { _filter_rel } +DUMP_VARS=( + ConfigBranch + ConfigFile + --Configuration + UPSTREAM DEVELOP FEATURE RELEASE MAIN TAG_PREFIX TAG_SUFFIX HOTFIX DIST NOAUTO + --Paramètres + CurrentBranch + SrcType SrcBranch + DestBranch +) + +function dump_action() { + for var in "${DUMP_VARS[@]}"; do + if [ "${var#--}" != "$var" ]; then + estep "${var#--}" + else + echo_setv "$var=${!var}" + fi + done +} + function show_action() { local commits setx commits=_list_commits @@ -111,24 +160,124 @@ function show_action() { fi } -function merge_action() { - die "action non implémentée" -} +################################################################################ +# Fusion de branche +################################################################################ -function _script_echo() { +function _mscript_echo() { echo >>"$script" echo "$comment$(qvals echo "$@")" >>"$script" } -function _script_add() { - [ $# -gt 0 ] && _script_echo "$*" +function _mscript_add() { + [ $# -gt 0 ] && _mscript_echo "$*" cat >>"$script" } -function _script_start() { +function _mscript_start() { >"$script" - _script_add <>"$script" + echo "$comment$(qvals echo "$@")" >>"$script" +} + +function _rscript_add() { + [ $# -gt 0 ] && _rscript_echo "$*" + cat >>"$script" +} + +function _rscript_start() { + >"$script" + _rscript_add <>"$changelog" - ;; - release) - enote "\ -Vous allez intégrer la branche de release ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE} -dans la branche destination ${COULEUR_VERTE}$DestBranch${COULEUR_NORMALE}" - ask_yesno "Voulez-vous continuer?" O || die - ;; - esac -} - -function release_upstream_action() { - merge_action "$@" -} - -function release_feature_action() { - merge_action "$@" -} - function _create_release_branch() { local date changelog @@ -188,15 +304,13 @@ function _create_release_branch() { "${EDITOR:-nano}" +7 "$changelog" [ -s "$changelog" ] || exit_with ewarn "Création de la release annulée" - _script_start - # créer la branche de release et basculer dessus - _script_add "* create branch $ReleaseBranch" <>CHANGES.md $(qvals echo "$(awk <"$changelog" ' BEGIN { p = 0 } @@ -207,42 +321,34 @@ git add CHANGES.md EOF # mettre à jour la version - _script_add "* update VERSION.txt" <VERSION.txt git add VERSION.txt EOF # Enregistrer les changements - _script_add "* commit" <