From 13d1704cb269acb1ee1a6d0d0a9e74cfcb7492ee Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 25 Feb 2025 15:51:46 +0400 Subject: [PATCH] maj projet --- wip/pman.conf => bash/src/pman.conf.sh | 4 +- bash/src/pman.sh | 225 ++++++++++++++++++++++ bash/src/pman74.conf.sh | 15 ++ bash/src/pman82.conf.sh | 15 ++ wip/_merge82 | 26 +-- wip/_rel74 | 1 - wip/_rel82 | 1 - wip/{npci => pci} | 0 wip/pman74.conf | 11 -- wip/pman82.conf | 11 -- wip/{npp => pp} | 0 wip/{_rel => prel} | 249 ++----------------------- wip/{npu => pu} | 0 13 files changed, 273 insertions(+), 285 deletions(-) rename wip/pman.conf => bash/src/pman.conf.sh (87%) create mode 100644 bash/src/pman.sh create mode 100644 bash/src/pman74.conf.sh create mode 100644 bash/src/pman82.conf.sh delete mode 120000 wip/_rel74 delete mode 120000 wip/_rel82 rename wip/{npci => pci} (100%) delete mode 100644 wip/pman74.conf delete mode 100644 wip/pman82.conf rename wip/{npp => pp} (100%) rename wip/{_rel => prel} (64%) rename wip/{npu => pu} (100%) diff --git a/wip/pman.conf b/bash/src/pman.conf.sh similarity index 87% rename from wip/pman.conf rename to bash/src/pman.conf.sh index 0286275..d174850 100644 --- a/wip/pman.conf +++ b/bash/src/pman.conf.sh @@ -1,6 +1,8 @@ # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 -# branche upload +## configuration par défaut + +# branche upstream UPSTREAM= # branches de développement DEVELOP=develop diff --git a/bash/src/pman.sh b/bash/src/pman.sh new file mode 100644 index 0000000..30bf849 --- /dev/null +++ b/bash/src/pman.sh @@ -0,0 +1,225 @@ +# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 + +# configuration par défaut +# doit être identique au contenu de pman.conf +# les branches sont mergées dans cet ordre: +# upstream --> develop --> [release -->] main --> dist +# feature _/ hotfix _/ +UPSTREAM= +DEVELOP=develop +FEATURE=wip/ +RELEASE=release- +MAIN=master +TAG_PREFIX= +TAG_SUFFIX= +HOTFIX=hotfix- +DIST= +NOAUTO= + +CONFIG_VARS=( + UPSTREAM DEVELOP FEATURE RELEASE MAIN TAG_PREFIX TAG_SUFFIX HOTFIX DIST NOAUTO +) + +function _init_changelog() { + setx date=date +%d/%m/%Y-%H:%M + ac_set_tmpfile changelog + echo >"$changelog" "\ +Vérifiez et complétez la liste des changements le cas échéant. +Un fichier vide annule l'opération +Ces lignes ne seront pas incluses dans le fichier destination +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +" +} + +function _filter_rel() { + # enlever les commits "techniques" générés par ce script + grep -v "Intégration de la branche $RELEASE" | + grep -v "Branche $DEVELOP en version .*-SNAPSHOT" +} + +function _filter_changes() { + # enlever les commits "inutiles" pour générer le fichier CHANGES.md + grep -vE '^([+|] )?[0-9a-f]+ modifs\.mineures sans commentaires$' | + grep -vE '^([+|] )?[0-9a-f]+ (cosmetic|typo|bug|fix|maj projet|maj deps)\$' +} + +function _format_md() { + awk ' +$0 == "" || $0 ~ /^#/ { print; next } +$1 == "+" { + $1 = "*" + $2 = "`" $2 "`" + print; next +} +$1 == "|" { + $1 = " *" + $2 = "`" $2 "`" + print; next +} +{ + $1 = "* `" $1 "`" + print; next +} +' +} + +function _list_commits() { + local source="${1:-$SrcBranch}" dest="${2:-$DestBranch}" mergebase + setx mergebase=git merge-base "$dest" "$source" + git log --oneline --graph "$mergebase..$source" | + grep -vF '|\' | grep -vF '|/' | sed 's/\* //; s/^ /+ /' | + _filter_rel +} + +function _script_echo() { + echo >>"$script" + echo "$comment$(qvals echo "$@")" >>"$script" +} + +function _script_add() { + [ $# -gt 0 ] && _script_echo "$*" + cat >>"$script" +} + +function _push_branches() { + local origin branch + _rscript_echo "* push branches" + for branch in "${push_branches[@]}"; do + origin="$Origin" + [ -n "$origin" ] || setx origin=git_get_branch_remote "$branch" + [ -n "$origin" ] || origin=origin + setx rbranch=git_get_branch_rbranch "$branch" "$origin" + if [ -n "$rbranch" ]; then + rbranch="${rbranch#refs/remotes/$origin/}" + _rscript_add <"$script" + _script_add <"$script" + _script_add <>"$changelog" "\ +## Release $Version du $date +" + _list_commits | _filter_changes | _format_md >>"$changelog" + "${EDITOR:-nano}" +7 "$changelog" + [ -s "$changelog" ] || exit_with ewarn "Création de la release annulée" + + # créer la branche de release et basculer dessus + _script_add "* create branch $ReleaseBranch" <>CHANGES.md +$(qvals echo "$(awk <"$changelog" ' +BEGIN { p = 0 } +p == 0 && $0 == "" { p = 1; next } +p == 1 { gsub(/\$/, "\\$", $0); print } +')") >>CHANGES.md +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" < $Dest" +exec "$MYDIR/prel" -bdev82 dev74 "$@" diff --git a/wip/_rel74 b/wip/_rel74 deleted file mode 120000 index 99051fd..0000000 --- a/wip/_rel74 +++ /dev/null @@ -1 +0,0 @@ -_rel \ No newline at end of file diff --git a/wip/_rel82 b/wip/_rel82 deleted file mode 120000 index 99051fd..0000000 --- a/wip/_rel82 +++ /dev/null @@ -1 +0,0 @@ -_rel \ No newline at end of file diff --git a/wip/npci b/wip/pci similarity index 100% rename from wip/npci rename to wip/pci diff --git a/wip/pman74.conf b/wip/pman74.conf deleted file mode 100644 index ba5edad..0000000 --- a/wip/pman74.conf +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 - -UPSTREAM= -DEVELOP=dev74 -FEATURE=wip74/ -RELEASE=rel74- -MAIN=dist74 -TAG_SUFFIX=p74 -HOTFIX=hotf74- -DIST= -NOAUTO= diff --git a/wip/pman82.conf b/wip/pman82.conf deleted file mode 100644 index 344e2f7..0000000 --- a/wip/pman82.conf +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 - -UPSTREAM= -DEVELOP=dev82 -FEATURE=wip82/ -RELEASE=rel82- -MAIN=dist82 -TAG_SUFFIX=p82 -HOTFIX=hotf82- -DIST= -NOAUTO= diff --git a/wip/npp b/wip/pp similarity index 100% rename from wip/npp rename to wip/pp diff --git a/wip/_rel b/wip/prel similarity index 64% rename from wip/_rel rename to wip/prel index 321b36f..aa62500 100755 --- a/wip/_rel +++ b/wip/prel @@ -1,24 +1,12 @@ #!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 source "$(dirname -- "$0")/../load.sh" || exit 1 -require: git +require: git pman pman.conf git_cleancheckout_DIRTY="\ Vous avez des modifications locales. Enregistrez ces modifications avant de créer une release" -# configuration par défaut -UPSTREAM= -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 @@ -41,8 +29,7 @@ function load_config() { ConfigFile=.pman.conf source "$ConfigFile" else - ConfigFile="$MYDIR/pman${MYNAME#_rel}.conf" - source "$ConfigFile" + require pman${MYNAME#prel}.conf fi SrcBranch="$1" @@ -90,51 +77,11 @@ 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" | - grep -v "Branche $DEVELOP en version .*-SNAPSHOT" -} - -function _filter_changes() { - # enlever les commits "inutiles" pour générer le fichier CHANGES.md - grep -vE '^([+|] )?[0-9a-f]+ modifs\.mineures sans commentaires$' | - grep -vE '^([+|] )?[0-9a-f]+ (cosmetic|typo|bug|fix|maj projet|maj deps)\$' -} - -function _format_md() { - awk ' -$0 == "" || $0 ~ /^#/ { print; next } -$1 == "+" { - $1 = "*" - $2 = "`" $2 "`" - print; next -} -$1 == "|" { - $1 = " *" - $2 = "`" $2 "`" - print; next -} -{ - $1 = "* `" $1 "`" - print; next -} -' -} - -function _list_commits() { - local source="${1:-$SrcBranch}" dest="${2:-$DestBranch}" mergebase - setx mergebase=git merge-base "$dest" "$source" - git log --oneline --graph "$mergebase..$source" | - grep -vF '|\' | grep -vF '|/' | sed 's/\* //; s/^ /+ /' | - _filter_rel -} - DUMP_VARS=( ConfigBranch ConfigFile --Configuration - UPSTREAM DEVELOP FEATURE RELEASE MAIN TAG_PREFIX TAG_SUFFIX HOTFIX DIST NOAUTO + "${CONFIG_VARS[@]}" --Paramètres CurrentBranch SrcType SrcBranch @@ -164,33 +111,6 @@ function show_action() { # Fusion de branche ################################################################################ -function _mscript_echo() { - echo >>"$script" - echo "$comment$(qvals echo "$@")" >>"$script" -} - -function _mscript_add() { - [ $# -gt 0 ] && _mscript_echo "$*" - cat >>"$script" -} - -function _mscript_start() { - >"$script" - _mscript_add <>"$script" - echo "$comment$(qvals echo "$@")" >>"$script" -} - -function _rscript_add() { - [ $# -gt 0 ] && _rscript_echo "$*" - cat >>"$script" -} - -function _rscript_start() { - >"$script" - _rscript_add <"$changelog" "\ -Vérifiez et complétez la liste des changements le cas échéant. -Un fichier vide annule la création de la release -Ces lignes ne seront pas incluses dans le fichier destination -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -" -} - -function _create_release_branch() { - local date changelog - - _init_changelog - echo >>"$changelog" "\ -## Release $Version du $date -" - _list_commits | _filter_changes | _format_md >>"$changelog" - "${EDITOR:-nano}" +7 "$changelog" - [ -s "$changelog" ] || exit_with ewarn "Création de la release annulée" - - # créer la branche de release et basculer dessus - _rscript_add "* create branch $ReleaseBranch" <>CHANGES.md -$(qvals echo "$(awk <"$changelog" ' -BEGIN { p = 0 } -p == 0 && $0 == "" { p = 1; next } -p == 1 { gsub(/\$/, "\\$", $0); print } -')") >>CHANGES.md -git add CHANGES.md -EOF - - # mettre à jour la version - _rscript_add "* update VERSION.txt" <VERSION.txt -git add VERSION.txt -EOF - - # Enregistrer les changements - _rscript_add "* commit" <