From 8ea5802429fe3053b716925fa93a7130d61737c2 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 20 Oct 2025 16:20:42 +0400 Subject: [PATCH] =?UTF-8?q?r=C3=A9organiser=20les=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash/src/pman.sh | 4 +- ...r_local_deps.php => .pcomp-local_deps.php} | 0 ..._profile.php => .pcomp-select_profile.php} | 0 wip/_pman.tool => bin/_pman | 10 + ...er_local_deps.php => pcomp-local_deps.php} | 0 ...t_profile.php => pcomp-select_profile.php} | 0 bin/pdev | 1 + bin/pdist | 1 + bin/pmain | 1 + bin/pwip | 61 +-- wip/pdev | 1 - wip/pdist | 1 - wip/pmain | 1 - wip/pman | 372 ------------------ bin/pman => wip/pman.orig | 0 wip/pmer | 262 ------------ bin/pmer => wip/pmer.orig | 0 wip/prel | 292 -------------- wip/pups | 1 - wip/pwip | 1 - wip/pwip.orig | 60 +++ 21 files changed, 75 insertions(+), 994 deletions(-) rename bin/{._pman-composer_local_deps.php => .pcomp-local_deps.php} (100%) rename bin/{._pman-composer_select_profile.php => .pcomp-select_profile.php} (100%) rename wip/_pman.tool => bin/_pman (93%) rename bin/{_pman-composer_local_deps.php => pcomp-local_deps.php} (100%) rename bin/{_pman-composer_select_profile.php => pcomp-select_profile.php} (100%) create mode 120000 bin/pdev create mode 120000 bin/pdist create mode 120000 bin/pmain mode change 100755 => 120000 bin/pwip delete mode 120000 wip/pdev delete mode 120000 wip/pdist delete mode 120000 wip/pmain delete mode 100755 wip/pman rename bin/pman => wip/pman.orig (100%) delete mode 100755 wip/pmer rename bin/pmer => wip/pmer.orig (100%) delete mode 100755 wip/prel delete mode 120000 wip/pups delete mode 120000 wip/pwip create mode 100755 wip/pwip.orig diff --git a/bash/src/pman.sh b/bash/src/pman.sh index 4cfc677..8558db8 100644 --- a/bash/src/pman.sh +++ b/bash/src/pman.sh @@ -30,7 +30,7 @@ CONFIG_VARS=( ################################################################################ -PMAN_TOOL_PUPS=UPSTREAM +PMAN_BRANCHES=(UPSTREAM DEVELOP FEATURE MAIN DIST) PMAN_TOOL_PDEV=DEVELOP PMAN_TOOL_PWIP=FEATURE PMAN_TOOL_PMAIN=MAIN @@ -130,8 +130,6 @@ function should_delete_merged() { * IfMergeDest -- nom effectif de la branche source *si elle existe*, vide sinon" -[ -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 diff --git a/bin/._pman-composer_local_deps.php b/bin/.pcomp-local_deps.php similarity index 100% rename from bin/._pman-composer_local_deps.php rename to bin/.pcomp-local_deps.php diff --git a/bin/._pman-composer_select_profile.php b/bin/.pcomp-select_profile.php similarity index 100% rename from bin/._pman-composer_select_profile.php rename to bin/.pcomp-select_profile.php diff --git a/wip/_pman.tool b/bin/_pman similarity index 93% rename from wip/_pman.tool rename to bin/_pman index 5782f54..1470581 100755 --- a/wip/_pman.tool +++ b/bin/_pman @@ -3,6 +3,16 @@ source "$(dirname -- "$0")/../load.sh" || exit 1 require: git pman pman.tool pman.conf +if [ "$MYNAME" == _pman ]; then + [ "$1" == --help ] && exit_with eecho "USAGE: _pman tool [args]" + PMAN_TOOL=_pman + PMAN_REF_BRANCH="${1^^}"; shift + array_contains PMAN_BRANCHES "$PMAN_REF_BRANCH" || die "$PMAN_REF_BRANCH: invalid branch" +else + PMAN_TOOL="${MYNAME^^}" + PMAN_REF_BRANCH="PMAN_TOOL_${PMAN_TOOL}"; PMAN_REF_BRANCH="${!PMAN_REF_BRANCH}" +fi + loaded_config= if check_gitdir; then load_branches all diff --git a/bin/_pman-composer_local_deps.php b/bin/pcomp-local_deps.php similarity index 100% rename from bin/_pman-composer_local_deps.php rename to bin/pcomp-local_deps.php diff --git a/bin/_pman-composer_select_profile.php b/bin/pcomp-select_profile.php similarity index 100% rename from bin/_pman-composer_select_profile.php rename to bin/pcomp-select_profile.php diff --git a/bin/pdev b/bin/pdev new file mode 120000 index 0000000..4568707 --- /dev/null +++ b/bin/pdev @@ -0,0 +1 @@ +_pman \ No newline at end of file diff --git a/bin/pdist b/bin/pdist new file mode 120000 index 0000000..4568707 --- /dev/null +++ b/bin/pdist @@ -0,0 +1 @@ +_pman \ No newline at end of file diff --git a/bin/pmain b/bin/pmain new file mode 120000 index 0000000..4568707 --- /dev/null +++ b/bin/pmain @@ -0,0 +1 @@ +_pman \ No newline at end of file diff --git a/bin/pwip b/bin/pwip deleted file mode 100755 index 787676b..0000000 --- a/bin/pwip +++ /dev/null @@ -1,60 +0,0 @@ -#!/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 - -git_cleancheckout_DIRTY="\ -Vous avez des modifications locales. -Enregistrez ces modifications avant de créer une nouvelle branche" - -chdir= -Origin= -ConfigBranch= -ConfigFile= -[ -z "$PMAN_NO_PUSH" ] && Push=1 || Push= -args=( - "créer une branche de feature" - "" - -d:,--chdir:BASEDIR chdir= "répertoire dans lequel se placer avant de lancer les opérations" - -O:,--origin Origin= "++\ -origine à partir de laquelle les branches distantes sont considérées" - -B:,--config-branch ConfigBranch= "++\ -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" - -n,--no-push Push= "\ -ne pas pousser les branches vers leur origine après la fusion" - --push Push=1 "++\ -pousser les branches vers leur origine après la fusion. -c'est l'option par défaut" -) -parse_args "$@"; set -- "${args[@]}" - -# charger la configuration -ensure_gitdir "$chdir" -load_branches all -load_config "$MYNAME" -load_branches current - -branch="$1" -if [ -z "$branch" -a ${#FeatureBranches[*]} -eq 1 ]; then - branch="${FeatureBranches[0]}" -fi -[ -n "$branch" ] || die "Vous devez spécifier la branche à créer" -branch="$FEATURE${branch#$FEATURE}" - -resolve_should_push -git_ensure_cleancheckout - -if array_contains AllBranches "$branch"; then - git checkout -q "$branch" -else - # si la branche source n'existe pas, la créer - args=(--origin "$Origin") - if [ -n "$ConfigFile" ]; then args+=(--config-file "$ConfigFile") - elif [ -n "$ConfigBranch" ]; then args+=(--config-branch "$ConfigBranch") - fi - [ -z "$Push" ] && args+=(--no-push) - exec "$MYDIR/pman" "${args[@]}" "$branch" -fi diff --git a/bin/pwip b/bin/pwip new file mode 120000 index 0000000..4568707 --- /dev/null +++ b/bin/pwip @@ -0,0 +1 @@ +_pman \ No newline at end of file diff --git a/wip/pdev b/wip/pdev deleted file mode 120000 index 065a97c..0000000 --- a/wip/pdev +++ /dev/null @@ -1 +0,0 @@ -_pman.tool \ No newline at end of file diff --git a/wip/pdist b/wip/pdist deleted file mode 120000 index 065a97c..0000000 --- a/wip/pdist +++ /dev/null @@ -1 +0,0 @@ -_pman.tool \ No newline at end of file diff --git a/wip/pmain b/wip/pmain deleted file mode 120000 index 065a97c..0000000 --- a/wip/pmain +++ /dev/null @@ -1 +0,0 @@ -_pman.tool \ No newline at end of file diff --git a/wip/pman b/wip/pman deleted file mode 100755 index 6679ca2..0000000 --- a/wip/pman +++ /dev/null @@ -1,372 +0,0 @@ -#!/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 - -################################################################################ -# Informations -################################################################################ - -SHOW_VARS=( - --Configuration - "${CONFIG_VARS[@]}" - --Paramètres - CurrentBranch - CurrentType=SrcType -) - -function show_action() { - local var src - echo_setv ConfigBranch="$ConfigBranch" - echo_setv ConfigFile="$(ppath "$ConfigFile")" - for var in "${SHOW_VARS[@]}"; do - if [ "${var#--}" != "$var" ]; then - estep "${var#--}" - else - splitfsep "$var" = var src - [ -n "$src" ] || src="$var" - echo_setv "$var=${!src}" - fi - done -} - -################################################################################ -# Initialisation -################################################################################ - -function _init_config() { - if [ ! -f .pman.conf -o -n "$ForceCreate" ]; then - ac_set_tmpfile config - cp "$ConfigFile" "$config" - "${EDITOR:-nano}" "$config" - [ -s "$config" ] || return 1 - - cp "$config" .pman.conf - if testdiff .pman.conf "$ConfigFile"; then - ConfigFile="$(pwd)/.pman.conf" - load_config - load_branches current "$SrcBranch" - fi - git add .pman.conf - fi - if [ ! -f ".gitignore" ]; then - echo >.gitignore "\ -.~lock*# -.*.swp" - git add .gitignore - fi - return 0 -} - -function init_repo_action() { - local -a push_branches; local config - - [ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé" - - _init_config || exit_with ewarn "Initialisation du dépôt annulée" - - einfo "Création de la branche $MAIN" - git symbolic-ref HEAD "refs/heads/$MAIN" - git commit -m "commit initial" - push_branches+=("$MAIN") - - einfo "Création de la branche $DEVELOP" - git checkout -b "$DEVELOP" - push_branches+=("$DEVELOP") - - _push_branches -} - -function init_config_action() { - local -a push_branches; local config - - [ -f .pman.conf -a -z "$ForceCreate" ] && die "La configuration pman a déjà été initialisée" - - resolve_should_push - - _init_config || exit_with ewarn "Initialisation de la configuration annulée" - git commit -m "configuration pman" - push_branches+=("$CurrentBranch") - - _push_branches -} - -function _init_composer() { - if [ ! -f .composer.pman.yml -o -n "$ForceCreate" ]; then - ac_set_tmpfile config - cat >"$config" <Intégration initiale de la branche $UPSTREAM" \ - -srecursive -Xours --allow-unrelated-histories \ - "$UPSTREAM" - push_branches+=("$DEVELOP") - - _push_branches - fi - git checkout -q "$UPSTREAM" -} - -function _ensure_dist_branch() { - [ -n "$DIST" ] || die "La branche DIST n'a pas été définie" - [ "$1" == init -o -n "$DistBranch" ] || die "$DIST: cette branche n'existe pas (le dépôt a-t-il été initialisé?)" -} - -function init_dist_action() { - local -a push_branches - - if [ -z "$DistBranch" ]; then - array_contains AllBranches "$DIST" && exit_with enote "\ -$DIST: une branche du même nom existe dans l'origine - git checkout $DIST" - _ensure_main_branch - _ensure_dist_branch init - - resolve_should_push - - enote "Vous allez créer la branche ${COULEUR_VERTE}$DIST${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$MAIN${COULEUR_NORMALE}" - ask_yesno "Voulez-vous continuer?" O || die - - einfo "Création de la branche $DIST" - git checkout -b "$DIST" "$MAIN" || die - push_branches+=("$DIST") - - _push_branches - fi - git checkout -q "$DIST" -} - -function init_feature_action() { - local -a push_branches; local branch - - [ -n "$FEATURE" ] || die "La branche FEATURE n'a pas été définie" - branch="${1#$FEATURE}" - [ -n "$branch" ] || die "Vous devez spécifier le nom de la branche" - branch="$FEATURE$branch" - - if ! array_contains LocalBranches "$branch"; then - array_contains AllBranches "$branch" && exit_with enote "\ -$branch: une branche du même nom existe dans l'origine - git checkout $branch" - _ensure_develop_branch - - resolve_should_push - - enote "Vous allez créer la branche ${COULEUR_VERTE}$branch${COULEUR_NORMALE} <-- ${COULEUR_BLEUE}$DEVELOP${COULEUR_NORMALE}" - ask_yesno "Voulez-vous continuer?" O || die - - einfo "Création de la branche $branch" - git checkout -b "$branch" "$DEVELOP" || die - push_branches+=("$branch") - - _push_branches - fi - git checkout -q "$branch" -} - -function init_action() { - local what="${1:-develop}"; shift - case "$what" in - init|repo|r) init_repo_action "$@";; - config) init_config_action "$@";; - composer) init_composer_action "$@";; - main|m) checkout_main_action;; - develop|dev|d) init_develop_action "$@";; - upstream|up|u) init_upstream_action "$@";; - dist|x) init_dist_action "$@";; - *) init_feature_action "$what" "$@";; - esac -} - -################################################################################ -# Programme principal -################################################################################ - -chdir= -ConfigBranch= -ConfigFile= -action=init -Origin= -[ -z "$PMAN_NO_PUSH" ] && Push=1 || Push= -ForceCreate= -args=( - "gérer un projet git" - "\ -repo|config|composer -develop|upstream|dist - -INITIALISATION - -Par défaut, le script agit en mode initialisation qui permet de créer et/ou -configurer certaines branches du dépôt si elles n'existent pas déjà - - repo - initialiser un dépôt vide et créer les branches $MAIN et $DEVELOP - - develop - créer la branche $DEVELOP - upstream - créer la branche ${UPSTREAM:-UPSTREAM} en tant que source de la branche $DEVELOP - dist - créer la branche ${DIST:-DIST} en tant que destination de la branche $MAIN - anything - créer la branche ${FEATURE}anything à partir de la branche $DEVELOP" - -d:,--chdir:BASEDIR chdir= "répertoire dans lequel se placer avant de lancer les opérations" - -B:,--config-branch ConfigBranch= "++\ -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" - -w,--show-config action=show "++\ -afficher la configuration chargée" - --composer-select-profile action=composer_select_profile "\ -sélectionner le profil composer spécifié en argument" - -O:,--origin Origin= "++\ -origine vers laquelle pousser les branches" - -n,--no-push Push= "\ -ne pas pousser les branches vers leur origine après leur création" - --push Push=1 "++\ -pousser les branches vers leur origine après leur création. -c'est l'option par défaut" - -f,--force-create ForceCreate=1 "\ -Avec config, forcer la (re)création du fichier .pman.conf" -) -parse_args "$@"; set -- "${args[@]}" - -# charger la configuration -ensure_gitdir "$chdir" -load_branches all -load_config "$MYNAME" -load_branches current - -# puis faire l'action que l'on nous demande -case "$action" in -show) - show_action "$@" - ;; -init) - git_ensure_cleancheckout - init_action "$@" - ;; -composer_select_profile) - exec "$MYDIR/_pman-$action.php" "$@" - ;; -*) - die "$action: action non implémentée" - ;; -esac diff --git a/bin/pman b/wip/pman.orig similarity index 100% rename from bin/pman rename to wip/pman.orig diff --git a/wip/pmer b/wip/pmer deleted file mode 100755 index 9a7daf8..0000000 --- a/wip/pmer +++ /dev/null @@ -1,262 +0,0 @@ -#!/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 - -git_cleancheckout_DIRTY="\ -Vous avez des modifications locales. -Enregistrez ces modifications avant de fusionner la branche" - -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 ensure_branches() { - [ -n "$SrcBranch" -a -n "$DestBranch" ] || - die "$SrcBranch: Aucune configuration de fusion trouvée pour cette branche" - - array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche source introuvable" - array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche destination introuvable" -} - -function merge_action() { - [ -z "$ShouldPush" ] && enote "\ -L'option --no-push a été forcée puisque ce dépôt n'a pas d'origine" - - 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 < - AFTER_MERGE_ - AFTER_DELETE_ - BEFORE_PUSH_ - AFTER_PUSH_ -srcType et destType pouvant valoir UPSTREAM, DEVELOP, FEATURE, RELEASE, MAIN, HOTFIX, DIST" - -d:,--chdir:BASEDIR chdir= "répertoire dans lequel se placer avant de lancer les opérations" - -O:,--origin Origin= "++\ -origine à partir de laquelle les branches distantes sont considérées" - -B:,--config-branch ConfigBranch= "++\ -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" - --fake _Fake=1 "++option non documentée" - --keep-script _KeepScript=1 "++option non documentée" - -w,--show '$action=show; inc@ ShowLevel' "\ -lister les modifications qui seraient fusionnées dans la branche destination" - -b,--rebase action=rebase "\ -lancer git rebase -i sur la branche source. cela permet de réordonner les -commits pour nettoyer l'historique avant la fusion" - --merge action=merge "++\ -fusionner la branche source dans la branche destination correspondante. -c'est l'action par défaut" - --tech-merge TechMerge=1 "++option non documentée" - -s:,--squash:COMMIT_MSG SquashMsg= "\ -fusionner les modifications de la branche comme un seul commit. -cette option ne devrait pas être utilisée avec --no-delete" - -n,--no-push Push= "\ -ne pas pousser les branches vers leur origine après la fusion" - --push Push=1 "++\ -pousser les branches vers leur origine après la fusion. -c'est l'option par défaut" - -k,--no-delete Delete= "\ -ne pas supprimer la branche après la fusion dans la destination" - --delete Delete=1 "++\ -supprimer la branche après la fusion dans la destination. -c'est l'option par défaut" - -f,--force-merge ForceMerge=1 "++\ -forcer la fusion pour une branche qui devrait être traitée par prel" - -a:,--after-merge AfterMerge= "\ -évaluer le script spécifié après une fusion *réussie*" -) -parse_args "$@"; set -- "${args[@]}" - -# charger la configuration -ensure_gitdir "$chdir" -load_branches all -load_config "$MYNAME" -load_branches current "$1" - -resolve_should_push quiet - -# puis faire l'action que l'on nous demande -case "$action" in -show) - git_check_cleancheckout || ewarn "$git_cleancheckout_DIRTY" - ensure_branches - show_action "$@" - ;; -merge) - ShouldDelete=1 - no_merge_msg="$SrcBranch: cette branche doit être fusionnée dans $DestBranch avec prel" - if [ "$SrcType" == develop ]; then - [ -z "$ForceMerge" ] && die "$no_merge_msg" - [ -n "$AfterMerge" ] || setx AfterMerge=qvals git checkout -q "$SrcBranch" - elif [ "$SrcType" == release -o "$SrcType" == hotfix ]; then - die "$no_merge_msg" - fi - # n'autoriser la suppression que pour feature - [ "$SrcType" == feature ] || ShouldDelete= - [ -z "$ShouldDelete" ] && Delete= - [ -z "$_Fake" ] && git_ensure_cleancheckout - if array_contains LocalBranches "$SrcBranch"; then - ensure_branches - merge_action "$@" - elif array_contains AllBranches "$SrcBranch"; then - enote "$SrcBranch: une branche du même nom existe dans l'origine" - die "$SrcBranch: branche locale introuvable" - else - die "$SrcBranch: branche introuvable" - fi - ;; -*) - die "$action: action non implémentée" - ;; -esac diff --git a/bin/pmer b/wip/pmer.orig similarity index 100% rename from bin/pmer rename to wip/pmer.orig diff --git a/wip/prel b/wip/prel deleted file mode 100755 index 2ec3a31..0000000 --- a/wip/prel +++ /dev/null @@ -1,292 +0,0 @@ -#!/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 - -git_cleancheckout_DIRTY="\ -Vous avez des modifications locales. -Enregistrez ces modifications avant de créer une release" - -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 ensure_branches() { - [ -n "$SrcBranch" -a -n "$DestBranch" ] || - die "$SrcBranch: Aucune configuration de fusion trouvée pour cette branche" - - array_contains LocalBranches "$SrcBranch" || die "$SrcBranch: branche source introuvable" - array_contains LocalBranches "$DestBranch" || die "$DestBranch: branche destination introuvable" - - Tag="$TAG_PREFIX$Version$TAG_SUFFIX" - local -a tags - setx -a tags=git tag -l "${TAG_PREFIX}*${TAG_SUFFIX}" - if [ -z "$ForceCreate" ]; then - array_contains tags "$Tag" && die "$Tag: le tag correspondant à la version existe déjà" - fi -} - -function create_release_action() { - if [ -n "$ReleaseBranch" ]; then - Version="${ReleaseBranch#$RELEASE}" - Tag="$TAG_PREFIX$Version$TAG_SUFFIX" - merge_release_action "$@"; return $? - elif [ -n "$HotfixBranch" ]; then - Version="${HotfixBranch#$HOTFIX}" - Tag="$TAG_PREFIX$Version$TAG_SUFFIX" - merge_hotfix_action "$@"; return $? - fi - - [ -n "$ManualRelease" ] && ewarn "\ -L'option --no-merge a été forcée puisque ce dépôt ne supporte pas les releases automatiques" - [ -z "$ShouldPush" ] && enote "\ -L'option --no-push a été forcée puisque ce dépôt n'a pas d'origine" - - if [ -z "$Version" -a -n "$CurrentVersion" -a -f VERSION.txt ]; then - Version="$(" + -d:,--chdir:BASEDIR chdir= "répertoire dans lequel se placer avant de lancer les opérations" + -O:,--origin Origin= "++\ +origine à partir de laquelle les branches distantes sont considérées" + -B:,--config-branch ConfigBranch= "++\ +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" + -n,--no-push Push= "\ +ne pas pousser les branches vers leur origine après la fusion" + --push Push=1 "++\ +pousser les branches vers leur origine après la fusion. +c'est l'option par défaut" +) +parse_args "$@"; set -- "${args[@]}" + +# charger la configuration +ensure_gitdir "$chdir" +load_branches all +load_config "$MYNAME" +load_branches current + +branch="$1" +if [ -z "$branch" -a ${#FeatureBranches[*]} -eq 1 ]; then + branch="${FeatureBranches[0]}" +fi +[ -n "$branch" ] || die "Vous devez spécifier la branche à créer" +branch="$FEATURE${branch#$FEATURE}" + +resolve_should_push +git_ensure_cleancheckout + +if array_contains AllBranches "$branch"; then + git checkout -q "$branch" +else + # si la branche source n'existe pas, la créer + args=(--origin "$Origin") + if [ -n "$ConfigFile" ]; then args+=(--config-file "$ConfigFile") + elif [ -n "$ConfigBranch" ]; then args+=(--config-branch "$ConfigBranch") + fi + [ -z "$Push" ] && args+=(--no-push) + exec "$MYDIR/pman" "${args[@]}" "$branch" +fi