From 0e5bf817a2f4f972d196dbe697f3dca7d6228dcd Mon Sep 17 00:00:00 2001 From: Jephte CLAIN Date: Thu, 19 Feb 2015 15:23:21 +0400 Subject: [PATCH] =?UTF-8?q?possibilit=C3=A9=20de=20lancer=20les=20commande?= =?UTF-8?q?s=20avanc=C3=A9es=20depuis=20la=20ligne=20de=20commande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/vcs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/ulib/vcs b/lib/ulib/vcs index 0441846..1a91bc8 100644 --- a/lib/ulib/vcs +++ b/lib/ulib/vcs @@ -181,11 +181,28 @@ function vcs_vcs_help() { uecho "uproject $1: Appeler le gestionnaire de version approprié avec les arguments donnés USAGE - uproject $1 [args]" + uproject $1 [args] + +note: les commandes suivantes permettent de lancer des opérations avancées: +$(array_to_lines __VCS_GIT_ADVANCED "" " ")" } function vcs_vcs() { _vcs_showhelp vcs "$@" && return + local i f t + for i in "${__VCS_GIT_ADVANCED_MAP[@]}"; do + splitpair "$i" f t + if [ "$1" == "$f" ]; then + shift + set -- "$t" "$@" + break + fi + done + if array_contains __VCS_GIT_ADVANCED "$1"; then + "$@" + return $? + fi + local type type="$(_vcs_get_type "$(_vcs_get_dir)")" || return "$type" "$@" @@ -499,6 +516,18 @@ function git_tag() { } # Fonctions avancées de git +__VCS_GIT_ADVANCED_MAP=( + lbs:git_list_branches rbs:git_list_rbranches + gb:git_get_branch ib:git_is_branch + hr:git_has_remote tb:git_track_branch + ic:git_check_cleancheckout ec:git_ensure_cleancheckout +) +__VCS_GIT_ADVANCED=( + git_list_branches git_list_rbranches + git_get_branch git_is_branch + git_has_remote git_track_branch + git_check_cleancheckout git_ensure_cleancheckout +) function git_list_branches() { git for-each-ref refs/heads/ --format='%(refname:short)' | csort } @@ -509,7 +538,7 @@ function git_get_branch() { git rev-parse --abbrev-ref HEAD 2>/dev/null } function git_is_branch() { - [ "$(get_branch)" == "${1:-master}" ] + [ "$(git_get_branch)" == "${1:-master}" ] } function git_has_remote() { [ -n "$(git config --get remote.${1:-origin}.url)" ] @@ -527,7 +556,7 @@ function git_check_cleancheckout() { [ -z "$(git status --porcelain 2>/dev/null)" ] } function git_ensure_cleancheckout() { - check_cleancheckout || die "Vous avez des modifications locales. Enregistrez ces modifications avant de continuer" + git_check_cleancheckout || die "Vous avez des modifications locales. Enregistrez ces modifications avant de continuer" } # fonctions pour git annex