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

View File

@ -73,43 +73,45 @@ Vous devrez:
local comment=
local or_die=" || exit 1"
_rscript_start
_script_add <<EOF
_scripta <<EOF
################################################################################
# create
if [ -n "\$create" ]; then
echo "== Création de la release"
esection "Création de la release"
EOF
_rscript_create_release_branch
_script_add <<EOF
_scripta <<EOF
fi
EOF
_script_add <<EOF
_scripta <<EOF
################################################################################
# merge
if [ -n "\$merge" ]; then
echo "== Fusionner la release"
esection "Fusionner la release"
EOF
_rscript_merge_release_branch "$DestBranch" "$Tag"
_rscript_merge_release_branch "$SrcBranch"
_rscript_delete_release_branch
_script_add <<EOF
_scripta <<EOF
fi
EOF
_script_add <<EOF
_scripta <<EOF
################################################################################
# push
if [ -n "\$push" ]; then
echo "== Pousser branches et tags"
esection "Pousser branches et tags"
EOF
_script_push_branches
_script_push_tags
_script_add <<EOF
_scripta <<EOF
fi
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"
die
elif [ -z "$_KeepScript" ]; then
@ -147,6 +149,7 @@ Version=
CurrentVersion=
Force=
_KeepScript=
_NoRunScript=
args=(
"faire une nouvelle release à partir de la branche 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
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"
--no-run-script _NoRunScript=1 "++option non documentée"
-w,--show action=show "\
lister les modifications qui seraient intégrées dans la release"
--release action=release "++\