#!/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 pman pman.conf "pman.tool.$MYNAME" git_cleancheckout_DIRTY="\ Vous avez des modifications locales. Enregistrez ces modifications avant de fusionner la branche" function dump_action() { echo -n "\ SRC_TYPE=$SRC_TYPE SRC_BRANCH=$SRC_BRANCH DEST_TYPE=$DEST_TYPE DEST_BRANCH=$DEST_BRANCH CurrentBranch=$CurrentBranch LocalBranches=${LocalBranches[*]} RemoteBranches=${RemoteBranches[*]} AllBranches=${AllBranches[*]} SrcType=$SrcType SrcBranch=$SrcBranch DestType=$DestType DestBranch=$DestBranch UpstreamBranch=$UpstreamBranch FeatureBranches=${FeatureBranches[*]} DevelopBranch=$DevelopBranch ReleaseBranch=$ReleaseBranch HotfixBranch=$HotfixBranch MainBranch=$MainBranch DistBranch=$DistBranch " } function _ensure_src_branch() { [ -n "$SrcBranch" ] || die "La branche $SRC_TYPE n'a pas été définie" [ "$1" == init -o -n "${!SRC_BRANCH}" ] || die "$SrcBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)" } function _ensure_dest_branch() { [ -n "$DestBranch" ] || die "La branche $DEST_TYPE n'a pas été définie" [ "$1" == init -o -n "${!DEST_BRANCH}" ] || die "$DestBranch: cette branche n'existe pas (le dépôt a-t-il été initialisé?)" } function checkout_action() { local -a push_branches if [ -z "${!SRC_BRANCH}" ]; then array_contains AllBranches "$SrcBranch" && exit_with enote "\ $SrcBranch: une branche du même nom existe dans l'origine git checkout $SrcBranch" _ensure_dest_branch _ensure_src_branch init resolve_should_push enote "Vous allez créer la branche ${COULEUR_BLEUE}$SrcBranch${COULEUR_NORMALE} <-- ${COULEUR_ROUGE}$DestBranch${COULEUR_NORMALE}" ask_yesno "Voulez-vous continuer?" O || die einfo "Création de la branche $SrcBranch" git checkout -b "$SrcBranch" "$DestBranch" || die push_branches+=("$SrcBranch") _push_branches fi git checkout "$SrcBranch" } function ensure_branches() { [ -n "${!SRC_BRANCH}" -a -n "${!DEST_BRANCH}" ] || die "${!SRC_BRANCH}: Aucune configuration de fusion trouvée pour cette branche" array_contains LocalBranches "${!SRC_BRANCH}" || die "${!SRC_BRANCH}: branche source introuvable" array_contains LocalBranches "${!DEST_BRANCH}" || die "${!DEST_BRANCH}: branche destination introuvable" } function _show_action() { local commits setx commits=_list_commits if [ -n "$commits" ]; then if [ $ShowLevel -ge 2 ]; then { echo "\ # Commits à fusionner ${!SRC_BRANCH} --> ${!DEST_BRANCH} $commits " _sd_COLOR=always _show_diff } | less -eRF else einfo "Commits à fusionner ${!SRC_BRANCH} --> ${!DEST_BRANCH}" eecho "$commits" fi fi } function show_action() { git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY" ensure_branches _show_action "$@" } function _merge_action() { enote "\ Ce script va - fusionner la branche ${COULEUR_BLEUE}${!SRC_BRANCH}${COULEUR_NORMALE} dans ${COULEUR_ROUGE}${!DEST_BRANCH}${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 <