diff --git a/bin/pman b/bin/pman index e97aae6..6b4e309 100755 --- a/bin/pman +++ b/bin/pman @@ -34,16 +34,12 @@ function show_action() { # Initialisation ################################################################################ -function init_repo_action() { - [ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé" - - local -a push_branches - +function _init_pman() { if [ ! -f .pman.conf ]; then ac_set_tmpfile config cp "$ConfigFile" "$config" "${EDITOR:-nano}" "$config" - [ -s "$config" ] || exit_with ewarn "Initialisation du dépôt annulée" + [ -s "$config" ] || return 1 cp "$config" .pman.conf if testdiff .pman.conf "$ConfigFile"; then @@ -59,6 +55,15 @@ function init_repo_action() { .*.swp" git add .gitignore fi + return 0 +} + +function init_repo_action() { + [ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé" + + local -a push_branches + + _init_pman || exit_with ewarn "Initialisation du dépôt annulée" einfo "Création de la branche $MAIN" git symbolic-ref HEAD "refs/heads/$MAIN" @@ -72,6 +77,17 @@ function init_repo_action() { _push_branches } +function init_pman_action() { + [ ${#LocalBranches[*]} -eq 0 ] || die "Ce dépôt a déjà été initialisé" + + local -a push_branches + + _init_pman || exit_with ewarn "Initialisation de pman annulée" + push_branches+=("$CurrentBranch") + + _push_branches +} + function init_develop_action() { if [ -z "$DevelopBranch" ]; then [ -n "$DEVELOP" ] || die "La branche DEVELOP n'a pas été définie" @@ -174,6 +190,7 @@ function init_action() { local what="${1:-develop}"; shift case "$what" in init|repo|r) init_repo_action "$@";; + pman) init_pman_action "$@";; main|m) git checkout -q "$MAIN";; develop|dev|d) init_develop_action "$@";; upstream|up|u) init_upstream_action "$@";;