merge est fait par un script
This commit is contained in:
parent
3a2c28b778
commit
0b403ee582
@ -87,23 +87,34 @@ function _scripta() {
|
||||
}
|
||||
|
||||
function _script_push_branches() {
|
||||
local origin branch
|
||||
_scripte einfo "push branches"
|
||||
[ ${#push_branches[*]} -gt 0 ] || return
|
||||
[ -n "$Origin" ] || Origin=origin
|
||||
git_have_remote "$Origin" || return
|
||||
|
||||
local branch cmd remote rbranch
|
||||
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/}"
|
||||
_scripta <<EOF
|
||||
$comment$(qvals git push "$origin" "$branch:$rbranch")$or_die
|
||||
EOF
|
||||
if [[ "$branch" == *:* ]]; then
|
||||
cmd="$(qvals git push "$Origin" "$branch")"
|
||||
else
|
||||
_scripta <<EOF
|
||||
$comment$(qvals git push --set-upstream "$origin" "$branch")$or_die
|
||||
EOF
|
||||
setx remote=git_get_branch_remote "$branch"
|
||||
if [ "$remote" == "$Origin" ]; then
|
||||
setx rbranch=git_get_branch_merge "$branch"
|
||||
if [ -n "$rbranch" ]; then
|
||||
# pousser vers la branche distante existante
|
||||
cmd="$(qvals git push "$Origin" "$branch:${rbranch#refs/heads/}")"
|
||||
else
|
||||
# pas de branche distante: pousser et traquer
|
||||
cmd="$(qvals git push -u "$Origin" "$branch:$branch")"
|
||||
fi
|
||||
elif [ -n "$remote" ]; then
|
||||
# pousser vers un remote différent
|
||||
cmd="$(qvals git push "$Origin" "$branch:$branch")"
|
||||
else
|
||||
# pas de remote: pousser et traquer
|
||||
cmd="$(qvals git push -u "$Origin" "$branch:$branch")"
|
||||
fi
|
||||
fi
|
||||
_scripta <<<"$comment$cmd$or_die"
|
||||
done
|
||||
}
|
||||
|
||||
@ -219,7 +230,7 @@ function _push_branches() {
|
||||
[ -n "$Origin" ] || Origin=origin
|
||||
git_have_remote "$Origin" || return
|
||||
|
||||
local -a cmds remote rbranch
|
||||
local -a cmds; local branch cmd remote rbranch
|
||||
for branch in "${push_branches[@]}"; do
|
||||
if [[ "$branch" == *:* ]]; then
|
||||
cmds+=("$(qvals git push "$Origin" "$branch")")
|
||||
@ -262,12 +273,15 @@ function _mscript_start() {
|
||||
>"$script"
|
||||
_scripta <<EOF
|
||||
#!/bin/bash
|
||||
$(qvals source "$NULIBDIR/load.sh") || exit 1
|
||||
|
||||
merge=
|
||||
delete=
|
||||
push=
|
||||
for arg in "\$@"; do
|
||||
case "\$arg" in
|
||||
merge) merge=1;;
|
||||
delete) delete=1;;
|
||||
push) push=1;;
|
||||
esac
|
||||
done
|
||||
@ -275,6 +289,38 @@ EOF
|
||||
chmod +x "$script"
|
||||
}
|
||||
|
||||
function _mscript_merge_branch() {
|
||||
local msg
|
||||
|
||||
# basculer sur la branche
|
||||
_scripta "switch to branch $DestBranch" <<EOF
|
||||
$comment$(qvals git checkout "$DestBranch")$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
|
||||
$comment$(qvals git commit -m "$msg")$or_die
|
||||
EOF
|
||||
else
|
||||
msg="Intégration de la branche $SrcBranch"
|
||||
[ -n "$TechMerge" ] && msg="<pman>$msg"
|
||||
_scripta "merge $SrcBranch" <<EOF
|
||||
$comment$(qvals git merge "$SrcBranch" --no-ff -m "$msg")$or_die
|
||||
EOF
|
||||
fi
|
||||
array_addu push_branches "$DestBranch"
|
||||
}
|
||||
|
||||
function _mscript_delete_branch() {
|
||||
_scripta "delete branch $SrcBranch" <<EOF
|
||||
$comment$(qvals git branch -D "$SrcBranch")$or_die
|
||||
EOF
|
||||
array_addu push_branches ":$SrcBranch"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Release
|
||||
|
||||
|
66
bin/pdev
66
bin/pdev
@ -25,37 +25,59 @@ function ensure_branches() {
|
||||
}
|
||||
|
||||
function merge_action() {
|
||||
local -a push_branches
|
||||
|
||||
enote "\
|
||||
Ce script va
|
||||
- fusionner la branche ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE} dans ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}${Push:+
|
||||
- pousser les branches modifiées}"
|
||||
ask_yesno "Voulez-vous continuer?" O || die
|
||||
|
||||
local -a push_branches; local msg
|
||||
local script=".git/rel-merge.sh"
|
||||
local -a push_branches
|
||||
local comment=
|
||||
local or_die=" || exit 1"
|
||||
|
||||
einfo "Fusion ${SquashMsg:+squash }dans $DestBranch"
|
||||
git checkout "$DestBranch" || die
|
||||
if [ -n "$SquashMsg" ]; then
|
||||
msg="$SquashMsg"
|
||||
[ -n "$TechMerge" ] && msg="<pman>$msg"
|
||||
git merge "$SrcBranch" --squash
|
||||
git commit -m "$msg"
|
||||
else
|
||||
msg="Intégration de la branche $SrcBranch"
|
||||
[ -n "$TechMerge" ] && msg="<pman>$msg"
|
||||
git merge "$SrcBranch" --no-ff -m "$msg"
|
||||
_mscript_start
|
||||
_scripta <<EOF
|
||||
################################################################################
|
||||
# merge
|
||||
if [ -n "\$merge" ]; then
|
||||
esection "Fusionner la branche"
|
||||
EOF
|
||||
_mscript_merge_branch
|
||||
_scripta <<EOF
|
||||
fi
|
||||
push_branches+=("$DestBranch")
|
||||
EOF
|
||||
|
||||
if [ -n "$Delete" ]; then
|
||||
einfo "Supprimer la branche $SrcBranch"
|
||||
git branch -D "$SrcBranch"
|
||||
push_branches+=(":$SrcBranch")
|
||||
_scripta <<EOF
|
||||
################################################################################
|
||||
# delete
|
||||
if [ -n "\$delete" ]; then
|
||||
esection "Supprimer la branche"
|
||||
EOF
|
||||
_mscript_delete_branch
|
||||
_scripta <<EOF
|
||||
fi
|
||||
EOF
|
||||
|
||||
_push_branches
|
||||
_scripta <<EOF
|
||||
################################################################################
|
||||
# push
|
||||
if [ -n "\$push" ]; then
|
||||
esection "Pousser les branches"
|
||||
EOF
|
||||
_script_push_branches
|
||||
_scripta <<EOF
|
||||
fi
|
||||
EOF
|
||||
|
||||
if [ -n "$_NoRunScript" ]; then
|
||||
einfo "Veuillez consulter le script $script pour le détail des opérations à effectuer"
|
||||
elif ! "$script" merge ${Delete:+delete} ${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
|
||||
rm "$script"
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@ -66,6 +88,8 @@ chdir=
|
||||
Origin=
|
||||
ConfigBranch=
|
||||
ConfigFile=
|
||||
_KeepScript=
|
||||
_NoRunScript=
|
||||
action=merge
|
||||
TechMerge=
|
||||
SquashMsg=
|
||||
@ -82,6 +106,8 @@ branche à partir de laquelle charger la configuration"
|
||||
-c:,--config-file:CONFIG ConfigFile= "++\
|
||||
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 fusionnées dans la branche destination"
|
||||
-b,--rebase action=rebase "\
|
||||
|
16
bin/prel
16
bin/prel
@ -26,15 +26,12 @@ function ensure_branches() {
|
||||
Tag="$TAG_PREFIX$Version$TAG_SUFFIX"
|
||||
local -a tags
|
||||
setx -a tags=git tag -l "${TAG_PREFIX}*${TAG_SUFFIX}"
|
||||
if [ -z "$Force" ]; then
|
||||
if [ -z "$ForceCreate" ]; then
|
||||
array_contains tags "$Tag" && die "$Tag: le tag correspondant à la version existe déjà"
|
||||
fi
|
||||
}
|
||||
|
||||
function create_release_action() {
|
||||
local script=".git/rel-release.sh"
|
||||
local -a push_branches push_tags
|
||||
|
||||
if [ -n "$ReleaseBranch" ]; then
|
||||
Version="${ReleaseBranch#$RELEASE}"
|
||||
merge_release_action "$@"; return $?
|
||||
@ -70,8 +67,11 @@ Vous devrez:
|
||||
fi
|
||||
ask_yesno "Voulez-vous continuer?" O || die
|
||||
|
||||
local script=".git/rel-release.sh"
|
||||
local -a push_branches push_tags
|
||||
local comment=
|
||||
local or_die=" || exit 1"
|
||||
|
||||
_rscript_start
|
||||
_scripta <<EOF
|
||||
################################################################################
|
||||
@ -142,14 +142,14 @@ chdir=
|
||||
Origin=
|
||||
ConfigBranch=
|
||||
ConfigFile=
|
||||
_KeepScript=
|
||||
_NoRunScript=
|
||||
action=release
|
||||
Merge=1
|
||||
Push=1
|
||||
Version=
|
||||
CurrentVersion=
|
||||
Force=
|
||||
_KeepScript=
|
||||
_NoRunScript=
|
||||
ForceCreate=
|
||||
args=(
|
||||
"faire une nouvelle release à partir de la branche source"
|
||||
" -v VERSION [source]"
|
||||
@ -182,7 +182,7 @@ c'est l'option par défaut"
|
||||
spécifier la version de la release à créer"
|
||||
-C,--current-version CurrentVersion=1 "++\
|
||||
si aucune version n'est spécifiée, prendre la version présente dans le fichier VERSION.txt"
|
||||
-f:,--force Force= "\
|
||||
-f:,--force-create ForceCreate= "\
|
||||
forcer la création de la release même si le tag correspond à la version existe déjà"
|
||||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
Reference in New Issue
Block a user