modifs.mineures sans commentaires
This commit is contained in:
parent
39abe09f11
commit
e99716735c
129
bash/src/pman.sh
129
bash/src/pman.sh
@ -28,27 +28,29 @@ CONFIG_VARS=(
|
|||||||
UPSTREAM DEVELOP FEATURE RELEASE MAIN TAG_PREFIX TAG_SUFFIX HOTFIX DIST NOAUTO
|
UPSTREAM DEVELOP FEATURE RELEASE MAIN TAG_PREFIX TAG_SUFFIX HOTFIX DIST NOAUTO
|
||||||
)
|
)
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
PMAN_TOOL_PUPS=UPSTREAM
|
PMAN_TOOL_PUPS=UPSTREAM
|
||||||
PMAN_TOOL_PDEV=DEVELOP
|
PMAN_TOOL_PDEV=DEVELOP
|
||||||
PMAN_TOOL_PWIP=FEATURE
|
PMAN_TOOL_PWIP=FEATURE
|
||||||
PMAN_TOOL_PMAIN=MAIN
|
PMAN_TOOL_PMAIN=MAIN
|
||||||
PMAN_TOOL_PDIST=DIST
|
PMAN_TOOL_PDIST=DIST
|
||||||
UPSTREAM_CREATE_BASE= ; UPSTREAM_MERGE_FROM= ; UPSTREAM_MERGE_TO=DEVELOP ; UPSTREAM_PREL= ; UPSTREAM_DELETE=
|
UPSTREAM_BASE= ; UPSTREAM_MERGE_FROM= ; UPSTREAM_MERGE_TO=DEVELOP ; UPSTREAM_PREL= ; UPSTREAM_DELETE=
|
||||||
DEVELOP_CREATE_BASE=MAIN ; DEVELOP_MERGE_FROM=FEATURE ; DEVELOP_MERGE_TO=MAIN ; DEVELOP_PREL=to ; DEVELOP_DELETE=from
|
DEVELOP_BASE=MAIN ; DEVELOP_MERGE_FROM=FEATURE ; DEVELOP_MERGE_TO=MAIN ; DEVELOP_PREL=to ; DEVELOP_DELETE=from
|
||||||
MAIN_CREATE_BASE= ; MAIN_MERGE_FROM=DEVELOP ; MAIN_MERGE_TO=DIST ; MAIN_PREL=from ; MAIN_DELETE=
|
MAIN_BASE= ; MAIN_MERGE_FROM=DEVELOP ; MAIN_MERGE_TO=DIST ; MAIN_PREL=from ; MAIN_DELETE=
|
||||||
DIST_CREATE_BASE=MAIN ; DIST_MERGE_FROM=MAIN ; DIST_MERGE_TO= ; DIST_PREL= ; DIST_DELETE=
|
DIST_BASE=MAIN ; DIST_MERGE_FROM=MAIN ; DIST_MERGE_TO= ; DIST_PREL= ; DIST_DELETE=
|
||||||
FEATURE_CREATE_BASE=DEVELOP ; FEATURE_MERGE_FROM= ; FEATURE_MERGE_TO=DEVELOP ; FEATURE_PREL= ; FEATURE_DELETE=to
|
FEATURE_BASE=DEVELOP ; FEATURE_MERGE_FROM= ; FEATURE_MERGE_TO=DEVELOP ; FEATURE_PREL= ; FEATURE_DELETE=to
|
||||||
|
|
||||||
function get_create_base() {
|
function get_base_branch() {
|
||||||
# afficher la branche depuis laquelle créer la branche $1
|
# afficher la branche depuis laquelle créer la branche $1
|
||||||
# retourner 1 en cas d'erreur (pas de branche source)
|
# retourner 1 en cas d'erreur (pas de branche source)
|
||||||
local branch="$1" infos
|
local branch="$1" infos
|
||||||
[ -n "$branch" ] || return 1
|
[ -n "$branch" ] || return 1
|
||||||
infos="${branch^^}_CREATE_BASE"; branch="${!infos}"
|
infos="${branch^^}_BASE"; branch="${!infos}"
|
||||||
[ -n "$branch" ] && echo "$branch" || return 1
|
[ -n "$branch" ] && echo "$branch" || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_merge_from() {
|
function get_merge_from_branch() {
|
||||||
# afficher la branche depuis laquelle la branche $1 doit merger
|
# afficher la branche depuis laquelle la branche $1 doit merger
|
||||||
# retourner 1 en cas d'erreur (pas de branche source)
|
# retourner 1 en cas d'erreur (pas de branche source)
|
||||||
local branch="$1" infos
|
local branch="$1" infos
|
||||||
@ -57,7 +59,7 @@ function get_merge_from() {
|
|||||||
[ -n "$branch" ] && echo "$branch" || return 1
|
[ -n "$branch" ] && echo "$branch" || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_merge_to() {
|
function get_merge_to_branch() {
|
||||||
# afficher la branche dans laquelle la branche $1 doit merger
|
# afficher la branche dans laquelle la branche $1 doit merger
|
||||||
# retourner 1 en cas d'erreur (pas de branche destination)
|
# retourner 1 en cas d'erreur (pas de branche destination)
|
||||||
local branch="$1" infos
|
local branch="$1" infos
|
||||||
@ -84,6 +86,94 @@ function should_delete_merged() {
|
|||||||
[ "${!infos}" == "$dir" ]
|
[ "${!infos}" == "$dir" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
: "
|
||||||
|
# description des variables #
|
||||||
|
|
||||||
|
* PMAN_TOOL -- nom de l'outil, e.g pdev, pmain, pdist
|
||||||
|
|
||||||
|
* PMAN_REF_BRANCH -- code de la branche de référence basé sur le nom de l'outil
|
||||||
|
* PmanRefBranch -- nom effectif de la branche si elle est définie dans
|
||||||
|
.pman.conf, vide sinon
|
||||||
|
* IfRefBranch -- nom effectif de la branche *si elle existe*, vide sinon
|
||||||
|
|
||||||
|
* PMAN_UNIQUE -- si la branche de référence est unique. est vide pour les
|
||||||
|
codes de branches multiples, telle que FEATURE
|
||||||
|
|
||||||
|
* PMAN_BASE_BRANCH -- branche de base à partir de laquelle créer la branche
|
||||||
|
de référence
|
||||||
|
* PmanBaseBranch -- nom effectif de la branche de base si elle est définie
|
||||||
|
dans .pman.conf, vide sinon
|
||||||
|
* IfBaseBranch -- nom effectif de la branche de base *si elle existe*, vide
|
||||||
|
sinon
|
||||||
|
|
||||||
|
* PMAN_MERGE_FROM -- code de la branche source à partir de laquelle la fusion
|
||||||
|
est faite dans PMAN_REF_BRANCH. vide si la branche n'a pas de source
|
||||||
|
* PMAN_MERGE_TO -- code de la branche destination dans laquelle la fusion est
|
||||||
|
faite depuis PMAN_REF_BRANCH. vide si la branche n'a pas de destination
|
||||||
|
* PMAN_DIR -- direction de la fusion:
|
||||||
|
'from' si on fait PMAN_MERGE_FROM --> PMAN_REF_BRANCH
|
||||||
|
'to' si on fait PMAN_REF_BRANCH --> PMAN_MERGE_TO
|
||||||
|
* PMAN_PREL_MERGE -- si la fusion devrait se faire avec prel
|
||||||
|
* PMAN_DELETE_MERGED -- s'il faut supprimer la branche source après la fusion
|
||||||
|
|
||||||
|
* PMAN_MERGE_SRC -- code de la branche source pour la fusion, ou vide si la
|
||||||
|
fusion n'est pas possible
|
||||||
|
* PmanMergeSrc -- nom effectif de la branche source si elle est définie
|
||||||
|
dans .pman.conf
|
||||||
|
* IfMergeSrc -- nom effectif de la branche source *si elle existe*, vide
|
||||||
|
sinon
|
||||||
|
|
||||||
|
* PMAN_MERGE_DEST -- code de la branche destination pour la fusion, ou vide si
|
||||||
|
la fusion n'est pas possible
|
||||||
|
* PmanMergeDest -- nom effectif de la branche destination si elle est
|
||||||
|
définie dans .pman.conf
|
||||||
|
* IfMergeDest -- nom effectif de la branche source *si elle existe*, vide
|
||||||
|
sinon
|
||||||
|
|
||||||
|
* PMAN_CAN_MERGE -- indique si la fusion est théoriquement possible, c'est à
|
||||||
|
dire que $PMAN_MERGE_SRC et $PMAN_MERGE_DEST sont tous les deux non vides
|
||||||
|
* IfCanMerge -- indique si la fusion est effectivement possible, c'est à dire
|
||||||
|
que $IfMergeSrc et $IfMergeDest sont tous les deux non vides"
|
||||||
|
|
||||||
|
[ -n "$PMAN_TOOL" ] || PMAN_TOOL="$MYNAME"
|
||||||
|
PMAN_REF_BRANCH="PMAN_TOOL_${PMAN_TOOL^^}"; PMAN_REF_BRANCH="${!PMAN_REF_BRANCH}"
|
||||||
|
function set_pman_vars() {
|
||||||
|
PmanRefBranch="${!PMAN_REF_BRANCH}"
|
||||||
|
case "$PMAN_REF_BRANCH" in
|
||||||
|
FEATURE|RELEASE|HOTFIX) PMAN_UNIQUE=;;
|
||||||
|
*) PMAN_UNIQUE=1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
PMAN_BASE_BRANCH=$(get_base_branch "$PMAN_REF_BRANCH")
|
||||||
|
[ -n "$PMAN_BASE_BRANCH" ] && PmanBaseBranch="${!PMAN_BASE_BRANCH}" || PmanBaseBranch=
|
||||||
|
|
||||||
|
PMAN_MERGE_FROM=$(get_merge_from_branch "$PMAN_REF_BRANCH")
|
||||||
|
PMAN_MERGE_TO=$(get_merge_to_branch "$PMAN_REF_BRANCH")
|
||||||
|
if [ -n "$1" ]; then PMAN_DIR="$1"
|
||||||
|
else PMAN_DIR=to
|
||||||
|
#elif [ -n "$PMAN_MERGE_TO" ]; then PMAN_DIR=to
|
||||||
|
#else PMAN_DIR=from
|
||||||
|
fi
|
||||||
|
PMAN_PREL_MERGE=$(should_prel_merge "$PMAN_REF_BRANCH" "$PMAN_DIR" && echo 1)
|
||||||
|
PMAN_DELETE_MERGED=$(should_delete_merged "$PMAN_REF_BRANCH" "$PMAN_DIR" && echo 1)
|
||||||
|
case "$PMAN_DIR" in
|
||||||
|
to)
|
||||||
|
PMAN_MERGE_SRC="$PMAN_REF_BRANCH"
|
||||||
|
PMAN_MERGE_DEST="$PMAN_MERGE_TO"
|
||||||
|
;;
|
||||||
|
from)
|
||||||
|
PMAN_MERGE_SRC="$PMAN_MERGE_FROM"
|
||||||
|
PMAN_MERGE_DEST="$PMAN_REF_BRANCH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -n "$PMAN_MERGE_SRC" -a -n "$PMAN_MERGE_DEST" ] && PMAN_CAN_MERGE=1 || PMAN_CAN_MERGE=
|
||||||
|
[ -n "$PMAN_MERGE_SRC" ] && PmanMergeSrc="${!PMAN_MERGE_SRC}" || PmanMergeSrc=
|
||||||
|
[ -n "$PMAN_MERGE_DEST" ] && PmanMergeDest="${!PMAN_MERGE_DEST}" || PmanMergeDest=
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
function _init_changelog() {
|
function _init_changelog() {
|
||||||
setx date=date +%d/%m/%Y-%H:%M
|
setx date=date +%d/%m/%Y-%H:%M
|
||||||
ac_set_tmpfile changelog
|
ac_set_tmpfile changelog
|
||||||
@ -257,10 +347,6 @@ function load_branches() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
local branch
|
local branch
|
||||||
PmanBranch=
|
|
||||||
PmanCreateBase=
|
|
||||||
PmanMergeSrc=
|
|
||||||
PmanMergeDest=
|
|
||||||
UpstreamBranch=
|
UpstreamBranch=
|
||||||
FeatureBranches=()
|
FeatureBranches=()
|
||||||
DevelopBranch=
|
DevelopBranch=
|
||||||
@ -268,15 +354,11 @@ function load_branches() {
|
|||||||
HotfixBranch=
|
HotfixBranch=
|
||||||
MainBranch=
|
MainBranch=
|
||||||
DistBranch=
|
DistBranch=
|
||||||
|
IfRefBranch=
|
||||||
|
IfBaseBranch=
|
||||||
|
IfMergeSrc=
|
||||||
|
IfMergeDest=
|
||||||
for branch in "${LocalBranches[@]}"; do
|
for branch in "${LocalBranches[@]}"; do
|
||||||
[ -n "$PMAN_BRANCH" ] && [ "$branch" == "${!PMAN_BRANCH}" ] &&
|
|
||||||
PmanBranch="$branch"
|
|
||||||
[ -n "$PMAN_CREATE_BASE" ] && [ "$branch" == "${!PMAN_CREATE_BASE}" ] &&
|
|
||||||
PmanCreateBase="$branch"
|
|
||||||
[ -n "$PMAN_MERGE_SRC" ] && [ "$branch" == "${!PMAN_MERGE_SRC}" ] &&
|
|
||||||
PmanMergeSrc="$branch"
|
|
||||||
[ -n "$PMAN_MERGE_DEST" ] && [ "$branch" == "${!PMAN_MERGE_DEST}" ] &&
|
|
||||||
PmanMergeDest="$branch"
|
|
||||||
if [ "$branch" == "$UPSTREAM" ]; then
|
if [ "$branch" == "$UPSTREAM" ]; then
|
||||||
UpstreamBranch="$branch"
|
UpstreamBranch="$branch"
|
||||||
elif [ -n "$FEATURE" ] && [[ "$branch" == "$FEATURE"* ]]; then
|
elif [ -n "$FEATURE" ] && [[ "$branch" == "$FEATURE"* ]]; then
|
||||||
@ -292,7 +374,12 @@ function load_branches() {
|
|||||||
elif [ -n "$DIST" -a "$branch" == "$DIST" ]; then
|
elif [ -n "$DIST" -a "$branch" == "$DIST" ]; then
|
||||||
DistBranch="$branch"
|
DistBranch="$branch"
|
||||||
fi
|
fi
|
||||||
|
[ -n "$PmanRefBranch" -a "$branch" == "$PmanRefBranch" ] && IfRefBranch="$branch"
|
||||||
|
[ -n "$PmanBaseBranch" -a "$branch" == "$PmanBaseBranch" ] && IfBaseBranch="$branch"
|
||||||
|
[ -n "$PmanMergeSrc" -a "$branch" == "$PmanMergeSrc" ] && IfMergeSrc="$branch"
|
||||||
|
[ -n "$PmanMergeDest" -a "$branch" == "$PmanMergeDest" ] && IfMergeDest="$branch"
|
||||||
done
|
done
|
||||||
|
[ -n "$IfMergeSrc" -a "$IfMergeDest" ] && IfCanMerge=1 || IfCanMerge=
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
299
bash/src/pman.tool.sh
Normal file
299
bash/src/pman.tool.sh
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
|
|
||||||
|
git_cleancheckout_DIRTY="\
|
||||||
|
Vous avez des modifications locales.
|
||||||
|
Enregistrez ces modifications avant de fusionner la branche"
|
||||||
|
|
||||||
|
function resolve_unique_branch() {
|
||||||
|
if [ "$PMAN_REF_BRANCH" == FEATURE ]; then
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
UniqueBranch="$FEATURE${1#$FEATURE}"
|
||||||
|
elif [[ "$CurrentBranch" == "$FEATURE"* ]]; then
|
||||||
|
UniqueBranch="$CurrentBranch"
|
||||||
|
elif [ ${#FeatureBranches[*]} -eq 0 ]; then
|
||||||
|
die "Vous devez spécifier la branche de feature"
|
||||||
|
elif [ ${#FeatureBranches[*]} -eq 1 ]; then
|
||||||
|
UniqueBranch="${FeatureBranches[0]}"
|
||||||
|
else
|
||||||
|
simple_menu \
|
||||||
|
UniqueBranch FeatureBranches \
|
||||||
|
-t "Branches de feature" \
|
||||||
|
-m "Veuillez choisir la branche de feature" \
|
||||||
|
-d "${FeatureBranches[0]}"
|
||||||
|
fi
|
||||||
|
PMAN_REF_BRANCH=UniqueBranch
|
||||||
|
PMAN_MERGE_SRC=UniqueBranch
|
||||||
|
else
|
||||||
|
die "resolve_unique_branch: $PMAN_REF_BRANCH: non implémenté"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function dump_action() {
|
||||||
|
enote "Valeurs des variables:
|
||||||
|
PMAN_TOOL=$PMAN_TOOL
|
||||||
|
PMAN_REF_BRANCH=$PMAN_REF_BRANCH${PmanRefBranch:+ PmanRefBranch=$PmanRefBranch IfRefBranch=$IfRefBranch}
|
||||||
|
PMAN_BASE_BRANCH=$PMAN_BASE_BRANCH${PmanBaseBranch:+ PmanBaseBranch=$PmanBaseBranch IfCreateBase=$IfCreateBase}
|
||||||
|
PMAN_MERGE_FROM=$PMAN_MERGE_FROM
|
||||||
|
PMAN_MERGE_TO=$PMAN_MERGE_TO
|
||||||
|
PMAN_DIR=$PMAN_DIR
|
||||||
|
PMAN_PREL_MERGE=$PMAN_PREL_MERGE
|
||||||
|
PMAN_DELETE_MERGED=$PMAN_DELETE_MERGED
|
||||||
|
PMAN_MERGE_SRC=$PMAN_MERGE_SRC${PmanMergeSrc:+ PmanMergeSrc=$PmanMergeSrc IfMergeSrc=$IfMergeSrc}
|
||||||
|
PMAN_MERGE_DEST=$PMAN_MERGE_DEST${PmanMergeDest:+ PmanMergeDest=$PmanMergeDest IfMergeDest=$IfMergeDest}
|
||||||
|
PMAN_CAN_MERGE=$PMAN_CAN_MERGE IfCanMerge=$IfCanMerge
|
||||||
|
|
||||||
|
CurrentBranch=$CurrentBranch
|
||||||
|
LocalBranches=${LocalBranches[*]}
|
||||||
|
RemoteBranches=${RemoteBranches[*]}
|
||||||
|
AllBranches=${AllBranches[*]}
|
||||||
|
|
||||||
|
UpstreamBranch=$UpstreamBranch
|
||||||
|
FeatureBranches=${FeatureBranches[*]}
|
||||||
|
DevelopBranch=$DevelopBranch
|
||||||
|
ReleaseBranch=$ReleaseBranch
|
||||||
|
HotfixBranch=$HotfixBranch
|
||||||
|
MainBranch=$MainBranch
|
||||||
|
DistBranch=$DistBranch
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _ensure_branch() {
|
||||||
|
[ -n "$PmanRefBranch" ] || die "\
|
||||||
|
La branche $PMAN_REF_BRANCH n'a pas été définie.
|
||||||
|
Veuillez éditer le fichier .pman.conf"
|
||||||
|
[ "$1" == init -o -n "$IfRefBranch" ] || die "$PmanRefBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _ensure_base_branch() {
|
||||||
|
[ -n "${!PMAN_BASE_BRANCH}" ] || die "\
|
||||||
|
La branche $PMAN_BASE_BRANCH n'a pas été définie.
|
||||||
|
Veuillez éditer le fichier .pman.conf"
|
||||||
|
[ "$1" == init -o -n "$IfCreateBase" ] || die "${!PMAN_BASE_BRANCH}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _ensure_merge_src() {
|
||||||
|
[ -n "$PmanMergeSrc" ] || die "\
|
||||||
|
La branche $PMAN_MERGE_SRC n'a pas été définie.
|
||||||
|
Veuillez éditer le fichier .pman.conf"
|
||||||
|
[ "$1" == init -o -n "$IfMergeSrc" ] || die "$PmanMergeSrc: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _ensure_merge_dest() {
|
||||||
|
[ -n "$PmanMergeDest" ] || die "\
|
||||||
|
La branche $PMAN_MERGE_DEST n'a pas été définie.
|
||||||
|
Veuillez éditer le fichier .pman.conf"
|
||||||
|
[ "$1" == init -o -n "$IfMergeDest" ] || die "$PmanMergeDest: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkout_action() {
|
||||||
|
local -a push_branches
|
||||||
|
|
||||||
|
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
|
||||||
|
_ensure_branch init
|
||||||
|
|
||||||
|
if [ -n "$IfRefBranch" ]; then
|
||||||
|
git checkout "$IfRefBranch"
|
||||||
|
elif array_contains LocalBranches "$PmanRefBranch"; then
|
||||||
|
git checkout "$PmanRefBranch"
|
||||||
|
elif array_contains AllBranches "$PmanRefBranch"; then
|
||||||
|
enote "$PmanRefBranch: une branche du même nom existe dans l'origine"
|
||||||
|
ask_yesno "Voulez-vous basculer sur cette branche?" O || die
|
||||||
|
git checkout "$PmanRefBranch"
|
||||||
|
elif [ -n "$PMAN_BASE_BRANCH" ]; then
|
||||||
|
_ensure_base_branch
|
||||||
|
|
||||||
|
resolve_should_push
|
||||||
|
|
||||||
|
local SrcBranch="${!PMAN_BASE_BRANCH}" DestBranch="$PmanRefBranch"
|
||||||
|
enote "Vous allez créer la branche ${COULEUR_BLEUE}$DestBranch${COULEUR_NORMALE} <-- ${COULEUR_ROUGE}$SrcBranch${COULEUR_NORMALE}"
|
||||||
|
ask_yesno "Voulez-vous continuer?" O || die
|
||||||
|
|
||||||
|
einfo "Création de la branche $DestBranch"
|
||||||
|
git checkout -b "$DestBranch" "$SrcBranch" || die
|
||||||
|
push_branches+=("$DestBranch")
|
||||||
|
|
||||||
|
_push_branches
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#XXXX
|
||||||
|
#[ -n "$PmanMergeSrc" ] ||
|
||||||
|
# die "Aucune branche définie pour $PMAN_MERGE_SRC. Veuillez éditer le fichier .pman.conf"
|
||||||
|
function ensure_merge_branches() {
|
||||||
|
[ -n "$PMAN_CAN_MERGE" ] ||
|
||||||
|
die "$PmanRefBranch: Aucune configuration de fusion trouvée pour cette branche"
|
||||||
|
|
||||||
|
local branches
|
||||||
|
[ "$1" == -a ] && branches=AllBranches || branches=LocalBranches
|
||||||
|
|
||||||
|
SrcBranch="$PmanMergeSrc"
|
||||||
|
array_contains "$branches" "$SrcBranch" || die "$SrcBranch: branche source introuvable"
|
||||||
|
DestBranch="$PmanMergeDest"
|
||||||
|
array_contains "$branches" "$DestBranch" || die "$DestBranch: branche destination introuvable"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _show_action() {
|
||||||
|
local commits
|
||||||
|
setx commits=_list_commits
|
||||||
|
if [ -n "$commits" ]; then
|
||||||
|
if [ $ShowLevel -ge 2 ]; then
|
||||||
|
{
|
||||||
|
echo "\
|
||||||
|
# Commits à fusionner $SrcBranch --> $DestBranch
|
||||||
|
|
||||||
|
$commits
|
||||||
|
"
|
||||||
|
_sd_COLOR=always _show_diff
|
||||||
|
} | less -eRF
|
||||||
|
else
|
||||||
|
einfo "Commits à fusionner $SrcBranch --> $DestBranch"
|
||||||
|
eecho "$commits"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_action() {
|
||||||
|
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
|
||||||
|
ensure_merge_branches
|
||||||
|
_show_action "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _merge_action() {
|
||||||
|
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 script=".git/pman-merge.sh"
|
||||||
|
local -a push_branches delete_branches
|
||||||
|
local hook
|
||||||
|
local comment=
|
||||||
|
local or_die=" || exit 1"
|
||||||
|
|
||||||
|
_mscript_start
|
||||||
|
_scripta <<EOF
|
||||||
|
################################################################################
|
||||||
|
# merge
|
||||||
|
if [ -n "\$merge" ]; then
|
||||||
|
esection "Fusionner la branche"
|
||||||
|
EOF
|
||||||
|
hook="BEFORE_MERGE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
||||||
|
(
|
||||||
|
${!hook}
|
||||||
|
)$or_die
|
||||||
|
EOF
|
||||||
|
_mscript_merge_branch
|
||||||
|
hook="AFTER_MERGE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
||||||
|
(
|
||||||
|
${!hook}
|
||||||
|
)$or_die
|
||||||
|
EOF
|
||||||
|
_scripta <<EOF
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ -n "$ShouldDelete" ]; then
|
||||||
|
_scripta <<EOF
|
||||||
|
################################################################################
|
||||||
|
# delete
|
||||||
|
if [ -n "\$delete" ]; then
|
||||||
|
esection "Supprimer la branche"
|
||||||
|
EOF
|
||||||
|
_mscript_delete_branch
|
||||||
|
hook="AFTER_DELETE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
||||||
|
(
|
||||||
|
${!hook}
|
||||||
|
)$or_die
|
||||||
|
EOF
|
||||||
|
_scripta <<EOF
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
_scripta <<EOF
|
||||||
|
################################################################################
|
||||||
|
# push
|
||||||
|
if [ -n "\$push" ]; then
|
||||||
|
esection "Pousser les branches"
|
||||||
|
EOF
|
||||||
|
hook="BEFORE_PUSH_$PMAN_MERGE_DEST"; [ -n "${!hook}" ] && _scripta <<EOF
|
||||||
|
(
|
||||||
|
${!hook}
|
||||||
|
)$or_die
|
||||||
|
EOF
|
||||||
|
_script_push_branches
|
||||||
|
if [ ${#delete_branches[*]} -gt 0 ]; then
|
||||||
|
_scripta <<<"if [ -n \"\$delete\" ]; then"
|
||||||
|
push_branches=("${delete_branches[@]}")
|
||||||
|
_script_push_branches
|
||||||
|
_scripta <<<fi
|
||||||
|
fi
|
||||||
|
hook="AFTER_PUSH_$PMAN_MERGE_DEST"; [ -n "${!hook}" ] && _scripta <<EOF
|
||||||
|
(
|
||||||
|
${!hook}
|
||||||
|
)$or_die
|
||||||
|
EOF
|
||||||
|
_scripta <<EOF
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
[ -n "$Delete" -o -z "$ShouldDelete" ] && Deleted=1 || Deleted=
|
||||||
|
[ -n "$ShouldDelete" -a -n "$Delete" ] && ShouldDelete=
|
||||||
|
[ -n "$ShouldPush" -a -n "$Push" ] && ShouldPush=
|
||||||
|
if [ -n "$_Fake" ]; then
|
||||||
|
cat "$script"
|
||||||
|
elif ! "$script" merge ${Delete:+delete} ${Push:+push}; then
|
||||||
|
eimportant "\
|
||||||
|
Le script $script a été lancé avec les arguments 'merge${Delete:+ delete}${Push:+ push}'
|
||||||
|
En cas d'erreur de merge, veuillez corriger les erreurs puis continuer avec
|
||||||
|
git merge --continue
|
||||||
|
Sinon, veuillez consulter le script et/ou le relancer
|
||||||
|
./$script${Delete:+ delete}${Push:+ push}"
|
||||||
|
die
|
||||||
|
elif [ -n "$Deleted" -a -n "$Push" ]; then
|
||||||
|
[ -n "$_KeepScript" ] || rm "$script"
|
||||||
|
[ -n "$AfterMerge" ] && eval "$AfterMerge"
|
||||||
|
else
|
||||||
|
local msg="\
|
||||||
|
Le script $script a été lancé avec les arguments 'merge${Delete:+ delete}${Push:+ push}'
|
||||||
|
Vous pouvez consulter le script et/ou le relancer
|
||||||
|
./$script${ShouldDelete:+ delete}${ShouldPush:+ push}"
|
||||||
|
[ -n "$AfterMerge" ] && msg="$msg
|
||||||
|
Il y a aussi les commandes supplémentaires suivantes:
|
||||||
|
${AfterMerge//
|
||||||
|
/
|
||||||
|
}"
|
||||||
|
einfo "$msg"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function merge_action() {
|
||||||
|
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
|
||||||
|
ensure_merge_branches -a
|
||||||
|
|
||||||
|
if [ -n "$PMAN_PREL_MERGE" ]; then
|
||||||
|
[ -n "$ForceMerge" ] || die "$SrcBranch: cette branche doit être fusionnée dans $DestBranch avec prel"
|
||||||
|
fi
|
||||||
|
[ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$SrcBranch"
|
||||||
|
[ -n "$PMAN_DELETE_MERGED" ] || Delete=
|
||||||
|
[ -z "$_Fake" ] && git_ensure_cleancheckout
|
||||||
|
|
||||||
|
if ! array_contains LocalBranches "$SrcBranch" && array_contains AllBranches "$SrcBranch"; then
|
||||||
|
enote "$SrcBranch: une branche du même nom existe dans l'origine"
|
||||||
|
fi
|
||||||
|
if ! array_contains LocalBranches "$DestBranch" && array_contains AllBranches "$DestBranch"; then
|
||||||
|
enote "$DestBranch: une branche du même nom existe dans l'origine"
|
||||||
|
fi
|
||||||
|
array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche locale introuvable"
|
||||||
|
array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche locale introuvable"
|
||||||
|
|
||||||
|
resolve_should_push
|
||||||
|
set -x #XXX
|
||||||
|
_merge_action "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebase_action() {
|
||||||
|
die "non implémenté"
|
||||||
|
}
|
||||||
|
|
396
wip/_pman.tool
396
wip/_pman.tool
@ -1,380 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
source "$(dirname -- "$0")/../load.sh" || exit 1
|
source "$(dirname -- "$0")/../load.sh" || exit 1
|
||||||
require: git pman pman.conf
|
require: git pman pman.tool pman.conf
|
||||||
|
|
||||||
git_cleancheckout_DIRTY="\
|
|
||||||
Vous avez des modifications locales.
|
|
||||||
Enregistrez ces modifications avant de fusionner la branche"
|
|
||||||
|
|
||||||
### description des variables ###
|
|
||||||
# * PMAN_TOOL -- nom de l'outil, e.g pdev, pmain, pdist
|
|
||||||
# * PMAN_BRANCH -- code de la branche de référence basé sur le nom de l'outil
|
|
||||||
# * PMAN_UNIQUE -- si cette branche est unique
|
|
||||||
# * PMAN_CREATE_BASE -- branche de base à partir de laquelle créer la branche
|
|
||||||
# * PMAN_MERGE_FROM -- code de la branche source à partir de laquelle la fusion
|
|
||||||
# est faite dans PMAN_BRANCH. vide si la branche n'a pas de source
|
|
||||||
# * PMAN_MERGE_TO -- code de la branche destination dans laquelle la fusion est
|
|
||||||
# faite depuis PMAN_BRANCH. vide si la branche n'a pas de destination
|
|
||||||
# * PMAN_DIR -- direction de la fusion:
|
|
||||||
# "from" si on fait PMAN_MERGE_FROM --> PMAN_BRANCH
|
|
||||||
# "to" si on fait PMAN_BRANCH --> PMAN_MERGE_TO
|
|
||||||
# * PMAN_PREL_MERGE -- si la fusion devrait se faire avec prel
|
|
||||||
# * PMAN_DELETE_MERGED -- s'il faut supprimer la branche source après la fusion
|
|
||||||
# * PMAN_MERGE_SRC -- code de la branche source pour la fusion, ou vide si la
|
|
||||||
# fusion n'est pas possible
|
|
||||||
# * PMAN_MERGE_DEST -- code de la branche destination pour la fusion, ou vide si
|
|
||||||
# la fusion n'est pas possible
|
|
||||||
# * PMAN_CAN_MERGE -- indique si la fusion est possible
|
|
||||||
# * ${!PMAN_BRANCH} -- nom effectif de la branche si elle est définie dans
|
|
||||||
# .pman.conf
|
|
||||||
# * $PmanBranch -- nom effectif de la branche *si elle existe*, vide sinon
|
|
||||||
# * ${!PMAN_MERGE_SRC} -- nom effectif de la branche source si elle est définie
|
|
||||||
# dans .pman.conf
|
|
||||||
# * $PmanMergeSrc -- nom effectif de la branche source *si elle existe*, vide
|
|
||||||
# sinon
|
|
||||||
# * ${!PMAN_MERGE_DEST} -- nom effectif de la branche destination si elle est
|
|
||||||
# définie dans .pman.conf
|
|
||||||
# * $PmanMergeDest -- nom effectif de la branche source *si elle existe*, vide
|
|
||||||
# sinon
|
|
||||||
|
|
||||||
[ -n "$PMAN_TOOL" ] || PMAN_TOOL="$MYNAME"
|
|
||||||
PMAN_BRANCH="PMAN_TOOL_${PMAN_TOOL^^}"; PMAN_BRANCH="${!PMAN_BRANCH}"
|
|
||||||
function set_pman_vars() {
|
|
||||||
case "$PMAN_BRANCH" in
|
|
||||||
FEATURE|RELEASE|HOTFIX) PMAN_UNIQUE=;;
|
|
||||||
*) PMAN_UNIQUE=1;;
|
|
||||||
esac
|
|
||||||
PMAN_CREATE_BASE=$(get_create_base "$PMAN_BRANCH")
|
|
||||||
PMAN_MERGE_FROM=$(get_merge_from "$PMAN_BRANCH")
|
|
||||||
PMAN_MERGE_TO=$(get_merge_to "$PMAN_BRANCH")
|
|
||||||
if [ -n "$1" ]; then PMAN_DIR="$1"
|
|
||||||
else PMAN_DIR=to
|
|
||||||
#elif [ -n "$PMAN_MERGE_TO" ]; then PMAN_DIR=to
|
|
||||||
#else PMAN_DIR=from
|
|
||||||
fi
|
|
||||||
PMAN_PREL_MERGE=$(should_prel_merge "$PMAN_BRANCH" "$PMAN_DIR" && echo 1)
|
|
||||||
PMAN_DELETE_MERGED=$(should_delete_merged "$PMAN_BRANCH" "$PMAN_DIR" && echo 1)
|
|
||||||
case "$PMAN_DIR" in
|
|
||||||
to)
|
|
||||||
PMAN_MERGE_SRC="$PMAN_BRANCH"
|
|
||||||
PMAN_MERGE_DEST="$PMAN_MERGE_TO"
|
|
||||||
;;
|
|
||||||
from)
|
|
||||||
PMAN_MERGE_SRC="$PMAN_MERGE_FROM"
|
|
||||||
PMAN_MERGE_DEST="$PMAN_BRANCH"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
[ -n "$PMAN_MERGE_SRC" -a -n "$PMAN_MERGE_DEST" ] && PMAN_CAN_MERGE=1 || PMAN_CAN_MERGE=
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolve_unique_branch() {
|
|
||||||
if [ "$PMAN_BRANCH" == FEATURE ]; then
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
UniqueBranch="$FEATURE${1#$FEATURE}"
|
|
||||||
elif [[ "$CurrentBranch" == "$FEATURE"* ]]; then
|
|
||||||
UniqueBranch="$CurrentBranch"
|
|
||||||
elif [ ${#FeatureBranches[*]} -eq 0 ]; then
|
|
||||||
die "Vous devez spécifier la branche de feature"
|
|
||||||
elif [ ${#FeatureBranches[*]} -eq 1 ]; then
|
|
||||||
UniqueBranch="${FeatureBranches[0]}"
|
|
||||||
else
|
|
||||||
simple_menu \
|
|
||||||
UniqueBranch FeatureBranches \
|
|
||||||
-t "Branches de feature" \
|
|
||||||
-m "Veuillez choisir la branche de feature" \
|
|
||||||
-d "${FeatureBranches[0]}"
|
|
||||||
fi
|
|
||||||
PMAN_BRANCH=UniqueBranch
|
|
||||||
PMAN_MERGE_SRC=UniqueBranch
|
|
||||||
else
|
|
||||||
die "resolve_unique_branch: $PMAN_BRANCH: non implémenté"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function dump_action() {
|
|
||||||
enote "Valeurs des variables:
|
|
||||||
PMAN_TOOL=$PMAN_TOOL
|
|
||||||
PMAN_BRANCH=$PMAN_BRANCH${PMAN_BRANCH:+ !PMAN_BRANCH=${!PMAN_BRANCH} PmanBranch=$PmanBranch}
|
|
||||||
PMAN_CREATE_BASE=$PMAN_CREATE_BASE${PMAN_CREATE_BASE:+ !PMAN_CREATE_BASE=${!PMAN_CREATE_BASE} PmanCreateBase=$PmanCreateBase}
|
|
||||||
PMAN_MERGE_FROM=$PMAN_MERGE_FROM
|
|
||||||
PMAN_MERGE_TO=$PMAN_MERGE_TO
|
|
||||||
PMAN_DIR=$PMAN_DIR
|
|
||||||
PMAN_PREL_MERGE=$PMAN_PREL_MERGE
|
|
||||||
PMAN_DELETE_MERGED=$PMAN_DELETE_MERGED
|
|
||||||
PMAN_MERGE_SRC=$PMAN_MERGE_SRC${PMAN_MERGE_SRC:+ !PMAN_MERGE_SRC=${!PMAN_MERGE_SRC} PmanMergeSrc=$PmanMergeSrc}
|
|
||||||
PMAN_MERGE_DEST=$PMAN_MERGE_DEST${PMAN_MERGE_DEST:+ !PMAN_MERGE_DEST=${!PMAN_MERGE_DEST} PmanMergeDest=$PmanMergeDest}
|
|
||||||
PMAN_CAN_MERGE=$PMAN_CAN_MERGE
|
|
||||||
|
|
||||||
CurrentBranch=$CurrentBranch
|
|
||||||
LocalBranches=${LocalBranches[*]}
|
|
||||||
RemoteBranches=${RemoteBranches[*]}
|
|
||||||
AllBranches=${AllBranches[*]}
|
|
||||||
|
|
||||||
UpstreamBranch=$UpstreamBranch
|
|
||||||
FeatureBranches=${FeatureBranches[*]}
|
|
||||||
DevelopBranch=$DevelopBranch
|
|
||||||
ReleaseBranch=$ReleaseBranch
|
|
||||||
HotfixBranch=$HotfixBranch
|
|
||||||
MainBranch=$MainBranch
|
|
||||||
DistBranch=$DistBranch
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _ensure_branch() {
|
|
||||||
[ -n "${!PMAN_BRANCH}" ] || die "\
|
|
||||||
La branche $PMAN_BRANCH n'a pas été définie.
|
|
||||||
Veuillez éditer le fichier .pman.conf"
|
|
||||||
[ "$1" == init -o -n "$PmanBranch" ] || die "${!PMAN_BRANCH}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _ensure_create_base() {
|
|
||||||
[ -n "${!PMAN_CREATE_BASE}" ] || die "\
|
|
||||||
La branche $PMAN_CREATE_BASE n'a pas été définie.
|
|
||||||
Veuillez éditer le fichier .pman.conf"
|
|
||||||
[ "$1" == init -o -n "$PmanCreateBase" ] || die "${!PMAN_CREATE_BASE}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _ensure_merge_src() {
|
|
||||||
[ -n "${!PMAN_MERGE_SRC}" ] || die "\
|
|
||||||
La branche $PMAN_MERGE_SRC n'a pas été définie.
|
|
||||||
Veuillez éditer le fichier .pman.conf"
|
|
||||||
[ "$1" == init -o -n "$PmanMergeSrc" ] || die "${!PMAN_MERGE_SRC}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _ensure_merge_dest() {
|
|
||||||
[ -n "${!PMAN_MERGE_DEST}" ] || die "\
|
|
||||||
La branche $PMAN_MERGE_DEST n'a pas été définie.
|
|
||||||
Veuillez éditer le fichier .pman.conf"
|
|
||||||
[ "$1" == init -o -n "$PmanMergeDest" ] || die "${!PMAN_MERGE_DEST}: cette branche n'existe pas (le dépôt a-t-il été initialisé?)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkout_action() {
|
|
||||||
local -a push_branches
|
|
||||||
|
|
||||||
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
|
|
||||||
_ensure_branch init
|
|
||||||
|
|
||||||
if [ -n "$PmanBranch" ]; then
|
|
||||||
git checkout "$PmanBranch"
|
|
||||||
elif array_contains LocalBranches "${!PMAN_BRANCH}"; then
|
|
||||||
git checkout "${!PMAN_BRANCH}"
|
|
||||||
elif array_contains AllBranches "${!PMAN_BRANCH}"; then
|
|
||||||
enote "${!PMAN_BRANCH}: une branche du même nom existe dans l'origine"
|
|
||||||
ask_yesno "Voulez-vous basculer sur cette branche?" O || die
|
|
||||||
git checkout "${!PMAN_BRANCH}"
|
|
||||||
elif [ -n "$PMAN_CREATE_BASE" ]; then
|
|
||||||
_ensure_create_base
|
|
||||||
|
|
||||||
resolve_should_push
|
|
||||||
|
|
||||||
local SrcBranch="${!PMAN_CREATE_BASE}" DestBranch="${!PMAN_BRANCH}"
|
|
||||||
enote "Vous allez créer la branche ${COULEUR_BLEUE}$DestBranch${COULEUR_NORMALE} <-- ${COULEUR_ROUGE}$SrcBranch${COULEUR_NORMALE}"
|
|
||||||
ask_yesno "Voulez-vous continuer?" O || die
|
|
||||||
|
|
||||||
einfo "Création de la branche $DestBranch"
|
|
||||||
git checkout -b "$DestBranch" "$SrcBranch" || die
|
|
||||||
push_branches+=("$DestBranch")
|
|
||||||
|
|
||||||
_push_branches
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#XXXX
|
|
||||||
#[ -n "${!PMAN_MERGE_SRC}" ] ||
|
|
||||||
# die "Aucune branche définie pour $PMAN_MERGE_SRC. Veuillez éditer le fichier .pman.conf"
|
|
||||||
function ensure_merge_branches() {
|
|
||||||
[ -n "$PMAN_CAN_MERGE" ] ||
|
|
||||||
die "${!PMAN_BRANCH}: Aucune configuration de fusion trouvée pour cette branche"
|
|
||||||
|
|
||||||
local branches
|
|
||||||
[ "$1" == -a ] && branches=AllBranches || branches=LocalBranches
|
|
||||||
|
|
||||||
SrcBranch="${!PMAN_MERGE_SRC}"
|
|
||||||
array_contains "$branches" "$SrcBranch" || die "$SrcBranch: branche source introuvable"
|
|
||||||
DestBranch="${!PMAN_MERGE_DEST}"
|
|
||||||
array_contains "$branches" "$DestBranch" || die "$DestBranch: branche destination introuvable"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _show_action() {
|
|
||||||
local commits
|
|
||||||
setx commits=_list_commits
|
|
||||||
if [ -n "$commits" ]; then
|
|
||||||
if [ $ShowLevel -ge 2 ]; then
|
|
||||||
{
|
|
||||||
echo "\
|
|
||||||
# Commits à fusionner $SrcBranch --> $DestBranch
|
|
||||||
|
|
||||||
$commits
|
|
||||||
"
|
|
||||||
_sd_COLOR=always _show_diff
|
|
||||||
} | less -eRF
|
|
||||||
else
|
|
||||||
einfo "Commits à fusionner $SrcBranch --> $DestBranch"
|
|
||||||
eecho "$commits"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_action() {
|
|
||||||
git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY"
|
|
||||||
ensure_merge_branches
|
|
||||||
_show_action "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _merge_action() {
|
|
||||||
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 script=".git/pman-merge.sh"
|
|
||||||
local -a push_branches delete_branches
|
|
||||||
local hook
|
|
||||||
local comment=
|
|
||||||
local or_die=" || exit 1"
|
|
||||||
|
|
||||||
_mscript_start
|
|
||||||
_scripta <<EOF
|
|
||||||
################################################################################
|
|
||||||
# merge
|
|
||||||
if [ -n "\$merge" ]; then
|
|
||||||
esection "Fusionner la branche"
|
|
||||||
EOF
|
|
||||||
hook="BEFORE_MERGE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
|
||||||
(
|
|
||||||
${!hook}
|
|
||||||
)$or_die
|
|
||||||
EOF
|
|
||||||
_mscript_merge_branch
|
|
||||||
hook="AFTER_MERGE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
|
||||||
(
|
|
||||||
${!hook}
|
|
||||||
)$or_die
|
|
||||||
EOF
|
|
||||||
_scripta <<EOF
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if [ -n "$ShouldDelete" ]; then
|
|
||||||
_scripta <<EOF
|
|
||||||
################################################################################
|
|
||||||
# delete
|
|
||||||
if [ -n "\$delete" ]; then
|
|
||||||
esection "Supprimer la branche"
|
|
||||||
EOF
|
|
||||||
_mscript_delete_branch
|
|
||||||
hook="AFTER_DELETE_$PMAN_MERGE_SRC"; [ -n "${!hook}" ] && _scripta <<EOF
|
|
||||||
(
|
|
||||||
${!hook}
|
|
||||||
)$or_die
|
|
||||||
EOF
|
|
||||||
_scripta <<EOF
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
_scripta <<EOF
|
|
||||||
################################################################################
|
|
||||||
# push
|
|
||||||
if [ -n "\$push" ]; then
|
|
||||||
esection "Pousser les branches"
|
|
||||||
EOF
|
|
||||||
hook="BEFORE_PUSH_$PMAN_MERGE_DEST"; [ -n "${!hook}" ] && _scripta <<EOF
|
|
||||||
(
|
|
||||||
${!hook}
|
|
||||||
)$or_die
|
|
||||||
EOF
|
|
||||||
_script_push_branches
|
|
||||||
if [ ${#delete_branches[*]} -gt 0 ]; then
|
|
||||||
_scripta <<<"if [ -n \"\$delete\" ]; then"
|
|
||||||
push_branches=("${delete_branches[@]}")
|
|
||||||
_script_push_branches
|
|
||||||
_scripta <<<fi
|
|
||||||
fi
|
|
||||||
hook="AFTER_PUSH_$PMAN_MERGE_DEST"; [ -n "${!hook}" ] && _scripta <<EOF
|
|
||||||
(
|
|
||||||
${!hook}
|
|
||||||
)$or_die
|
|
||||||
EOF
|
|
||||||
_scripta <<EOF
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
||||||
[ -n "$Delete" -o -z "$ShouldDelete" ] && Deleted=1 || Deleted=
|
|
||||||
[ -n "$ShouldDelete" -a -n "$Delete" ] && ShouldDelete=
|
|
||||||
[ -n "$ShouldPush" -a -n "$Push" ] && ShouldPush=
|
|
||||||
if [ -n "$_Fake" ]; then
|
|
||||||
cat "$script"
|
|
||||||
elif ! "$script" merge ${Delete:+delete} ${Push:+push}; then
|
|
||||||
eimportant "\
|
|
||||||
Le script $script a été lancé avec les arguments 'merge${Delete:+ delete}${Push:+ push}'
|
|
||||||
En cas d'erreur de merge, veuillez corriger les erreurs puis continuer avec
|
|
||||||
git merge --continue
|
|
||||||
Sinon, veuillez consulter le script et/ou le relancer
|
|
||||||
./$script${Delete:+ delete}${Push:+ push}"
|
|
||||||
die
|
|
||||||
elif [ -n "$Deleted" -a -n "$Push" ]; then
|
|
||||||
[ -n "$_KeepScript" ] || rm "$script"
|
|
||||||
[ -n "$AfterMerge" ] && eval "$AfterMerge"
|
|
||||||
else
|
|
||||||
local msg="\
|
|
||||||
Le script $script a été lancé avec les arguments 'merge${Delete:+ delete}${Push:+ push}'
|
|
||||||
Vous pouvez consulter le script et/ou le relancer
|
|
||||||
./$script${ShouldDelete:+ delete}${ShouldPush:+ push}"
|
|
||||||
[ -n "$AfterMerge" ] && msg="$msg
|
|
||||||
Il y a aussi les commandes supplémentaires suivantes:
|
|
||||||
${AfterMerge//
|
|
||||||
/
|
|
||||||
}"
|
|
||||||
einfo "$msg"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function merge_action() {
|
|
||||||
[ -n "$PMAN_UNIQUE" ] || resolve_unique_branch "$@" || die
|
|
||||||
ensure_merge_branches -a
|
|
||||||
|
|
||||||
if [ -n "$PMAN_PREL_MERGE" ]; then
|
|
||||||
[ -n "$ForceMerge" ] || die "$SrcBranch: cette branche doit être fusionnée dans $DestBranch avec prel"
|
|
||||||
fi
|
|
||||||
[ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$SrcBranch"
|
|
||||||
[ -n "$PMAN_DELETE_MERGED" ] || Delete=
|
|
||||||
[ -z "$_Fake" ] && git_ensure_cleancheckout
|
|
||||||
|
|
||||||
if ! array_contains LocalBranches "$SrcBranch" && array_contains AllBranches "$SrcBranch"; then
|
|
||||||
enote "$SrcBranch: une branche du même nom existe dans l'origine"
|
|
||||||
fi
|
|
||||||
if ! array_contains LocalBranches "$DestBranch" && array_contains AllBranches "$DestBranch"; then
|
|
||||||
enote "$DestBranch: une branche du même nom existe dans l'origine"
|
|
||||||
fi
|
|
||||||
array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche locale introuvable"
|
|
||||||
array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche locale introuvable"
|
|
||||||
|
|
||||||
resolve_should_push
|
|
||||||
set -x #XXX
|
|
||||||
_merge_action "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function rebase_action() {
|
|
||||||
die "non implémenté"
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Programme principal
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
loaded_config=
|
loaded_config=
|
||||||
if check_gitdir; then
|
if check_gitdir; then
|
||||||
load_branches all
|
load_branches all
|
||||||
load_config
|
load_config
|
||||||
set_pman_vars
|
set_pman_vars
|
||||||
if [ -n "${!PMAN_MERGE_SRC}" ]; then
|
if [ -n "$PmanMergeSrc" ]; then
|
||||||
load_branches current "${!PMAN_MERGE_SRC}"
|
load_branches current "$PmanMergeSrc"
|
||||||
loaded_config=1
|
loaded_config=1
|
||||||
elif [ -n "${!PMAN_BRANCH}" ]; then
|
elif [ -n "$PmanRefBranch" ]; then
|
||||||
load_branches current "${!PMAN_BRANCH}"
|
load_branches current "$PmanRefBranch"
|
||||||
loaded_config=1
|
loaded_config=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -384,19 +22,19 @@ fi
|
|||||||
BranchDesc=
|
BranchDesc=
|
||||||
MergeSrcDesc=
|
MergeSrcDesc=
|
||||||
MergeDestDesc=
|
MergeDestDesc=
|
||||||
if [ -n "$PMAN_BRANCH" ]; then
|
if [ -n "$PMAN_REF_BRANCH" ]; then
|
||||||
BranchDesc="${COULEUR_BLANCHE}<$PMAN_BRANCH>"
|
BranchDesc="${COULEUR_BLANCHE}<$PMAN_REF_BRANCH>"
|
||||||
[ -n "${!PMAN_BRANCH}" -a -n "$PMAN_UNIQUE" ] && BranchDesc="$BranchDesc (${!PMAN_BRANCH})"
|
[ -n "$PmanRefBranch" -a -n "$PMAN_UNIQUE" ] && BranchDesc="$BranchDesc ($PmanRefBranch)"
|
||||||
BranchDesc="$BranchDesc${COULEUR_NORMALE}"
|
BranchDesc="$BranchDesc${COULEUR_NORMALE}"
|
||||||
fi
|
fi
|
||||||
if [ -n "$PMAN_MERGE_SRC" ]; then
|
if [ -n "$PMAN_MERGE_SRC" ]; then
|
||||||
MergeSrcDesc="${COULEUR_BLEUE}<$PMAN_MERGE_SRC>"
|
MergeSrcDesc="${COULEUR_BLEUE}<$PMAN_MERGE_SRC>"
|
||||||
[ -n "${!PMAN_MERGE_SRC}" -a -n "$PMAN_UNIQUE" ] && MergeSrcDesc="$MergeSrcDesc (${!PMAN_MERGE_SRC})"
|
[ -n "$PmanMergeSrc" -a -n "$PMAN_UNIQUE" ] && MergeSrcDesc="$MergeSrcDesc ($PmanMergeSrc)"
|
||||||
MergeSrcDesc="$MergeSrcDesc${COULEUR_NORMALE}"
|
MergeSrcDesc="$MergeSrcDesc${COULEUR_NORMALE}"
|
||||||
fi
|
fi
|
||||||
if [ -n "$PMAN_MERGE_DEST" ]; then
|
if [ -n "$PMAN_MERGE_DEST" ]; then
|
||||||
MergeDestDesc="${COULEUR_ROUGE}<$PMAN_MERGE_DEST>"
|
MergeDestDesc="${COULEUR_ROUGE}<$PMAN_MERGE_DEST>"
|
||||||
[ -n "${!PMAN_MERGE_DEST}" -a -n "$PMAN_UNIQUE" ] && MergeDestDesc="$MergeDestDesc (${!PMAN_MERGE_DEST})"
|
[ -n "$PmanMergeDest" -a -n "$PMAN_UNIQUE" ] && MergeDestDesc="$MergeDestDesc ($PmanMergeDest)"
|
||||||
MergeDestDesc="$MergeDestDesc${COULEUR_NORMALE}"
|
MergeDestDesc="$MergeDestDesc${COULEUR_NORMALE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -420,7 +58,7 @@ du dépôt est utilisé par défaut s'il existe. cette option est prioritaire su
|
|||||||
--keep-script _KeepScript=1 "++option non documentée"
|
--keep-script _KeepScript=1 "++option non documentée"
|
||||||
--dump action=dump "++afficher les noms des branches"
|
--dump action=dump "++afficher les noms des branches"
|
||||||
)
|
)
|
||||||
if [ -n "$PmanBranch" -a -n "$PMAN_UNIQUE" ]; then
|
if [ -n "$PmanRefBranch" -a -n "$PMAN_UNIQUE" ]; then
|
||||||
args+=(
|
args+=(
|
||||||
--checkout action=checkout "++\
|
--checkout action=checkout "++\
|
||||||
créer le cas échéant la branche $BranchDesc et basculer vers elle.
|
créer le cas échéant la branche $BranchDesc et basculer vers elle.
|
||||||
@ -444,10 +82,10 @@ if [ -n "$PMAN_CAN_MERGE" ]; then
|
|||||||
if [ -n "$PMAN_UNIQUE" ]; then
|
if [ -n "$PMAN_UNIQUE" ]; then
|
||||||
usage="${usage}|--show|--merge"
|
usage="${usage}|--show|--merge"
|
||||||
else
|
else
|
||||||
usage="${usage} $PMAN_BRANCH
|
usage="${usage} $PMAN_REF_BRANCH
|
||||||
--show|--merge"
|
--show|--merge"
|
||||||
fi
|
fi
|
||||||
if [ "$PMAN_BRANCH" != "$PMAN_MERGE_SRC" ]; then
|
if [ "$PMAN_REF_BRANCH" != "$PMAN_MERGE_SRC" ]; then
|
||||||
usage="$usage
|
usage="$usage
|
||||||
|
|
||||||
NB: du fait de la configuration des branches, la fusion se fait dans le sens
|
NB: du fait de la configuration des branches, la fusion se fait dans le sens
|
||||||
@ -542,10 +180,10 @@ if [ -z "$loaded_config" -o -n "$chdir" -o -n "$ConfigFile" -o -n "$ConfigBranch
|
|||||||
load_branches all
|
load_branches all
|
||||||
load_config
|
load_config
|
||||||
set_pman_vars
|
set_pman_vars
|
||||||
if [ -n "${!PMAN_MERGE_SRC}" ]; then
|
if [ -n "$PmanMergeSrc" ]; then
|
||||||
load_branches current "${!PMAN_MERGE_SRC}"
|
load_branches current "$PmanMergeSrc"
|
||||||
elif [ -n "${!PMAN_BRANCH}" ]; then
|
elif [ -n "$PmanRefBranch" ]; then
|
||||||
load_branches current "${!PMAN_BRANCH}"
|
load_branches current "$PmanRefBranch"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
resolve_should_push quiet
|
resolve_should_push quiet
|
||||||
|
Loading…
x
Reference in New Issue
Block a user