This commit is contained in:
Jephté Clain 2025-02-28 09:08:00 +04:00
parent 39302bca61
commit 3a2c28b778
2 changed files with 34 additions and 29 deletions

View File

@ -76,19 +76,19 @@ function _list_commits() {
_filter_rel _filter_rel
} }
function _script_echo() { function _scripte() {
echo >>"$script" echo >>"$script"
echo "$comment$(qvals echo "$@")" >>"$script" echo "$comment$(qvals "$@")" >>"$script"
} }
function _script_add() { function _scripta() {
[ $# -gt 0 ] && _script_echo "$*" [ $# -gt 0 ] && _scripte einfo "$*"
cat >>"$script" cat >>"$script"
} }
function _script_push_branches() { function _script_push_branches() {
local origin branch local origin branch
_script_echo "* push branches" _scripte einfo "push branches"
for branch in "${push_branches[@]}"; do for branch in "${push_branches[@]}"; do
origin="$Origin" origin="$Origin"
[ -n "$origin" ] || setx origin=git_get_branch_remote "$branch" [ -n "$origin" ] || setx origin=git_get_branch_remote "$branch"
@ -96,11 +96,11 @@ function _script_push_branches() {
setx rbranch=git_get_branch_rbranch "$branch" "$origin" setx rbranch=git_get_branch_rbranch "$branch" "$origin"
if [ -n "$rbranch" ]; then if [ -n "$rbranch" ]; then
rbranch="${rbranch#refs/remotes/$origin/}" rbranch="${rbranch#refs/remotes/$origin/}"
_script_add <<EOF _scripta <<EOF
$comment$(qvals git push "$origin" "$branch:$rbranch")$or_die $comment$(qvals git push "$origin" "$branch:$rbranch")$or_die
EOF EOF
else else
_script_add <<EOF _scripta <<EOF
$comment$(qvals git push --set-upstream "$origin" "$branch")$or_die $comment$(qvals git push --set-upstream "$origin" "$branch")$or_die
EOF EOF
fi fi
@ -109,11 +109,11 @@ EOF
function _script_push_tags() { function _script_push_tags() {
local origin tag local origin tag
_script_echo "* push tags" _scripte einfo "push tags"
for tag in "${push_tags[@]}"; do for tag in "${push_tags[@]}"; do
origin="$Origin" origin="$Origin"
[ -n "$origin" ] || origin=origin [ -n "$origin" ] || origin=origin
_script_add <<EOF _scripta <<EOF
$comment$(qvals git push --force "$origin" tag "$tag")$or_die $comment$(qvals git push --force "$origin" tag "$tag")$or_die
EOF EOF
done done
@ -260,7 +260,7 @@ function _push_branches() {
function _mscript_start() { function _mscript_start() {
>"$script" >"$script"
_script_add <<EOF _scripta <<EOF
#!/bin/bash #!/bin/bash
merge= merge=
@ -280,8 +280,9 @@ EOF
function _rscript_start() { function _rscript_start() {
>"$script" >"$script"
_script_add <<EOF _scripta <<EOF
#!/bin/bash #!/bin/bash
$(qvals source "$NULIBDIR/load.sh") || exit 1
create= create=
merge= merge=
@ -313,12 +314,12 @@ function _rscript_create_release_branch() {
[ -s "$changelog" ] || exit_with ewarn "Création de la release annulée" [ -s "$changelog" ] || exit_with ewarn "Création de la release annulée"
# créer la branche de release et basculer dessus # créer la branche de release et basculer dessus
_script_add "* create branch $ReleaseBranch" <<EOF _scripta "create branch $ReleaseBranch" <<EOF
$(qvals git checkout -b "$ReleaseBranch" "$SrcBranch")$or_die $(qvals git checkout -b "$ReleaseBranch" "$SrcBranch")$or_die
EOF EOF
# créer le changelog # créer le changelog
_script_add "* update CHANGES.md" <<EOF _scripta "update CHANGES.md" <<EOF
$(qvals echo "$(awk <"$changelog" ' $(qvals echo "$(awk <"$changelog" '
BEGIN { p = 0 } BEGIN { p = 0 }
p == 0 && $0 == "" { p = 1; next } p == 0 && $0 == "" { p = 1; next }
@ -328,13 +329,13 @@ git add CHANGES.md
EOF EOF
# mettre à jour la version # mettre à jour la version
_script_add "* update VERSION.txt" <<EOF _scripta "update VERSION.txt" <<EOF
$(qvals echo "$Version") >VERSION.txt $(qvals echo "$Version") >VERSION.txt
git add VERSION.txt git add VERSION.txt
EOF EOF
# Enregistrer les changements # Enregistrer les changements
_script_add "* commit" <<EOF _scripta "commit" <<EOF
$(qvals git commit -m "<pman>Init changelog & version $Version") $(qvals git commit -m "<pman>Init changelog & version $Version")
EOF EOF
} }
@ -343,19 +344,19 @@ function _rscript_merge_release_branch() {
local dest="$1" tag="$2" local dest="$1" tag="$2"
# basculer sur la branche # basculer sur la branche
_script_add "* switch to branch $dest" <<EOF _scripta "switch to branch $dest" <<EOF
$comment$(qvals git checkout "$dest")$or_die $comment$(qvals git checkout "$dest")$or_die
EOF EOF
# fusionner la branche de release # fusionner la branche de release
_script_add "* merge branch $ReleaseBranch" <<EOF _scripta "merge branch $ReleaseBranch" <<EOF
$comment$(qvals git merge "$ReleaseBranch" -m "<pman>Intégration de la branche $ReleaseBranch" --no-ff)$or_die $comment$(qvals git merge "$ReleaseBranch" -m "<pman>Intégration de la branche $ReleaseBranch" --no-ff)$or_die
EOF EOF
array_addu push_branches "$dest" array_addu push_branches "$dest"
# tagger la release # tagger la release
if [ -n "$tag" ]; then if [ -n "$tag" ]; then
_script_add "* create tag $tag" <<EOF _scripta "create tag $tag" <<EOF
$comment$(qvals git tag --force "$tag")$or_die $comment$(qvals git tag --force "$tag")$or_die
EOF EOF
array_addu push_tags "$tag" array_addu push_tags "$tag"
@ -363,7 +364,7 @@ EOF
} }
function _rscript_delete_release_branch() { function _rscript_delete_release_branch() {
_script_add "* delete branch $ReleaseBranch" <<EOF _scripta "delete branch $ReleaseBranch" <<EOF
$comment$(qvals git branch -D "$ReleaseBranch")$or_die $comment$(qvals git branch -D "$ReleaseBranch")$or_die
EOF EOF
} }

View File

@ -73,43 +73,45 @@ Vous devrez:
local comment= local comment=
local or_die=" || exit 1" local or_die=" || exit 1"
_rscript_start _rscript_start
_script_add <<EOF _scripta <<EOF
################################################################################ ################################################################################
# create # create
if [ -n "\$create" ]; then if [ -n "\$create" ]; then
echo "== Création de la release" esection "Création de la release"
EOF EOF
_rscript_create_release_branch _rscript_create_release_branch
_script_add <<EOF _scripta <<EOF
fi fi
EOF EOF
_script_add <<EOF _scripta <<EOF
################################################################################ ################################################################################
# merge # merge
if [ -n "\$merge" ]; then if [ -n "\$merge" ]; then
echo "== Fusionner la release" esection "Fusionner la release"
EOF EOF
_rscript_merge_release_branch "$DestBranch" "$Tag" _rscript_merge_release_branch "$DestBranch" "$Tag"
_rscript_merge_release_branch "$SrcBranch" _rscript_merge_release_branch "$SrcBranch"
_rscript_delete_release_branch _rscript_delete_release_branch
_script_add <<EOF _scripta <<EOF
fi fi
EOF EOF
_script_add <<EOF _scripta <<EOF
################################################################################ ################################################################################
# push # push
if [ -n "\$push" ]; then if [ -n "\$push" ]; then
echo "== Pousser branches et tags" esection "Pousser branches et tags"
EOF EOF
_script_push_branches _script_push_branches
_script_push_tags _script_push_tags
_script_add <<EOF _scripta <<EOF
fi fi
EOF EOF
if ! "$script" create ${Merge:+merge} ${Push:+push}; then if [ -n "$_NoRunScript" ]; then
einfo "Veuillez consulter le script $script pour le détail des opérations à effectuer"
elif ! "$script" create ${Merge:+merge} ${Push:+push}; then
eimportant "Veuillez consulter le script $script pour le détail des opérations qui n'ont pas pu êtres effectuées" eimportant "Veuillez consulter le script $script pour le détail des opérations qui n'ont pas pu êtres effectuées"
die die
elif [ -z "$_KeepScript" ]; then elif [ -z "$_KeepScript" ]; then
@ -147,6 +149,7 @@ Version=
CurrentVersion= CurrentVersion=
Force= Force=
_KeepScript= _KeepScript=
_NoRunScript=
args=( args=(
"faire une nouvelle release à partir de la branche source" "faire une nouvelle release à partir de la branche source"
" -v VERSION [source]" " -v VERSION [source]"
@ -159,6 +162,7 @@ branche à partir de laquelle charger la configuration"
fichier de configuration des branches. cette option est prioritaire sur --config-branch fichier de configuration des branches. cette option est prioritaire sur --config-branch
par défaut, utiliser le fichier .pman.conf dans le répertoire du dépôt s'il existe" par défaut, utiliser le fichier .pman.conf dans le répertoire du dépôt s'il existe"
--keep-script _KeepScript=1 "++option non documentée" --keep-script _KeepScript=1 "++option non documentée"
--no-run-script _NoRunScript=1 "++option non documentée"
-w,--show action=show "\ -w,--show action=show "\
lister les modifications qui seraient intégrées dans la release" lister les modifications qui seraient intégrées dans la release"
--release action=release "++\ --release action=release "++\