ajout pwip
This commit is contained in:
parent
9a2378ba74
commit
e129e0aa7f
@ -159,6 +159,7 @@ function load_branches() {
|
|||||||
local what="${1:-all}"; shift
|
local what="${1:-all}"; shift
|
||||||
case "$what" in
|
case "$what" in
|
||||||
all)
|
all)
|
||||||
|
[ -n "$Origin" ] || Origin=origin
|
||||||
setx CurrentBranch=git_get_branch
|
setx CurrentBranch=git_get_branch
|
||||||
setx -a LocalBranches=git_list_branches
|
setx -a LocalBranches=git_list_branches
|
||||||
setx -a RemoteBranches=git_list_rbranches "$Origin"
|
setx -a RemoteBranches=git_list_rbranches "$Origin"
|
||||||
@ -195,12 +196,12 @@ function load_branches() {
|
|||||||
ReleaseBranch=
|
ReleaseBranch=
|
||||||
HotfixBranch=
|
HotfixBranch=
|
||||||
MainBranch=
|
MainBranch=
|
||||||
Dist=Branch
|
DistBranch=
|
||||||
for branch in "${AllBranches[@]}"; do
|
for branch in "${LocalBranches[@]}"; do
|
||||||
if [ "$branch" == "$UPSTREAM" ]; then
|
if [ "$branch" == "$UPSTREAM" ]; then
|
||||||
UpstreamBranch="$branch"
|
UpstreamBranch="$branch"
|
||||||
elif [[ "$branch" == "$FEATURE"* ]]; then
|
elif [[ "$branch" == "$FEATURE"* ]]; then
|
||||||
FeatureBranch+=("$branch")
|
FeatureBranches+=("$branch")
|
||||||
elif [ "$branch" == "$DEVELOP" ]; then
|
elif [ "$branch" == "$DEVELOP" ]; then
|
||||||
DevelopBranch="$branch"
|
DevelopBranch="$branch"
|
||||||
elif [[ "$branch" == "$RELEASE"* ]]; then
|
elif [[ "$branch" == "$RELEASE"* ]]; then
|
||||||
@ -252,6 +253,16 @@ function load_config() {
|
|||||||
################################################################################
|
################################################################################
|
||||||
# Divers
|
# Divers
|
||||||
|
|
||||||
|
function resolve_should_push() {
|
||||||
|
local quiet="$1"
|
||||||
|
ShouldPush=1
|
||||||
|
if ! git_have_remote "$Origin" && [ -n "$Push" ]; then
|
||||||
|
[ -n "$quiet" ] || enote "L'option --no-push a été forcée puisque ce dépôt n'a pas d'origine"
|
||||||
|
ShouldPush=
|
||||||
|
fi
|
||||||
|
[ -z "$ShouldPush" ] && Push=
|
||||||
|
}
|
||||||
|
|
||||||
function _push_branches() {
|
function _push_branches() {
|
||||||
[ ${#push_branches[*]} -gt 0 ] || return
|
[ ${#push_branches[*]} -gt 0 ] || return
|
||||||
[ -n "$Origin" ] || Origin=origin
|
[ -n "$Origin" ] || Origin=origin
|
||||||
|
24
bin/pdev
24
bin/pdev
@ -139,7 +139,7 @@ args=(
|
|||||||
" [source]
|
" [source]
|
||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
Le fichier .pman.conf contient la configuration des branches.Les variables
|
Le fichier .pman.conf contient la configuration des branches. Les variables
|
||||||
supplémentaires suivantes peuvent être définies:
|
supplémentaires suivantes peuvent être définies:
|
||||||
AFTER_MERGE_<srcType>
|
AFTER_MERGE_<srcType>
|
||||||
AFTER_DELETE_<srcType>
|
AFTER_DELETE_<srcType>
|
||||||
@ -186,12 +186,7 @@ load_branches all
|
|||||||
load_config "$MYNAME"
|
load_config "$MYNAME"
|
||||||
load_branches current "$1"
|
load_branches current "$1"
|
||||||
|
|
||||||
ShouldPush=1
|
resolve_should_push quiet
|
||||||
[ -n "$Origin" ] || Origin=origin
|
|
||||||
if ! git_have_remote "$Origin" && [ -n "$Push" ]; then
|
|
||||||
ShouldPush=
|
|
||||||
fi
|
|
||||||
[ -z "$ShouldPush" ] && Push=
|
|
||||||
|
|
||||||
# puis faire l'action que l'on nous demande
|
# puis faire l'action que l'on nous demande
|
||||||
case "$action" in
|
case "$action" in
|
||||||
@ -213,17 +208,14 @@ merge)
|
|||||||
esac
|
esac
|
||||||
[ -z "$ShouldDelete" ] && Delete=
|
[ -z "$ShouldDelete" ] && Delete=
|
||||||
git_ensure_cleancheckout
|
git_ensure_cleancheckout
|
||||||
if ! array_contains LocalBranches "$SrcBranch"; then
|
if array_contains LocalBranches "$SrcBranch"; then
|
||||||
# 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[@]}" "$FEATURE${SrcBranch#$FEATURE}"
|
|
||||||
else
|
|
||||||
ensure_branches
|
ensure_branches
|
||||||
merge_action "$@"
|
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
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
11
bin/pman
11
bin/pman
@ -34,16 +34,6 @@ function show_action() {
|
|||||||
# Initialisation
|
# Initialisation
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
function resolve_should_push() {
|
|
||||||
ShouldPush=1
|
|
||||||
[ -n "$Origin" ] || Origin=origin
|
|
||||||
if ! git_have_remote "$Origin" && [ -n "$Push" ]; then
|
|
||||||
enote "L'option --no-push a été forcée puisque ce dépôt n'a pas d'origine"
|
|
||||||
ShouldPush=
|
|
||||||
fi
|
|
||||||
[ -z "$ShouldPush" ] && Push=
|
|
||||||
}
|
|
||||||
|
|
||||||
function _init_config() {
|
function _init_config() {
|
||||||
if [ ! -f .pman.conf -o -n "$ForceCreate" ]; then
|
if [ ! -f .pman.conf -o -n "$ForceCreate" ]; then
|
||||||
ac_set_tmpfile config
|
ac_set_tmpfile config
|
||||||
@ -73,7 +63,6 @@ function init_repo_action() {
|
|||||||
|
|
||||||
[ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé"
|
[ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé"
|
||||||
|
|
||||||
[ -n "$Origin" ] || Origin=origin
|
|
||||||
_init_config || exit_with ewarn "Initialisation du dépôt annulée"
|
_init_config || exit_with ewarn "Initialisation du dépôt annulée"
|
||||||
|
|
||||||
einfo "Création de la branche $MAIN"
|
einfo "Création de la branche $MAIN"
|
||||||
|
12
bin/prel
12
bin/prel
@ -189,9 +189,8 @@ args=(
|
|||||||
" -v VERSION [source]
|
" -v VERSION [source]
|
||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
Le fichier .pman.conf contient la configuration des branches
|
Le fichier .pman.conf contient la configuration des branches. Les variables
|
||||||
|
supplémentaires suivantes peuvent être définies:
|
||||||
Les variables supplémentaires suivantes peuvent être définies:
|
|
||||||
AFTER_CREATE_RELEASE
|
AFTER_CREATE_RELEASE
|
||||||
AFTER_MERGE_RELEASE
|
AFTER_MERGE_RELEASE
|
||||||
AFTER_PUSH_RELEASE"
|
AFTER_PUSH_RELEASE"
|
||||||
@ -239,12 +238,7 @@ load_branches current "$1"; shift
|
|||||||
[ -n "$ManualRelease" ] && Merge=
|
[ -n "$ManualRelease" ] && Merge=
|
||||||
[ -z "$Merge" ] && Push=
|
[ -z "$Merge" ] && Push=
|
||||||
|
|
||||||
ShouldPush=1
|
resolve_should_push quiet
|
||||||
[ -n "$Origin" ] || Origin=origin
|
|
||||||
if ! git_have_remote "$Origin" && [ -n "$Push" ]; then
|
|
||||||
ShouldPush=
|
|
||||||
fi
|
|
||||||
[ -z "$ShouldPush" ] && Push=
|
|
||||||
|
|
||||||
# puis faire l'action que l'on nous demande
|
# puis faire l'action que l'on nous demande
|
||||||
case "$action" in
|
case "$action" in
|
||||||
|
60
bin/pwip
Executable file
60
bin/pwip
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/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"
|
||||||
|
"<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
|
Loading…
Reference in New Issue
Block a user