ajout quelques fonctions pour aider à travailler avec git
This commit is contained in:
parent
afbf8fcddf
commit
cd6b0e062a
32
lib/ulib/vcs
32
lib/ulib/vcs
|
@ -487,6 +487,38 @@ function git_tag() {
|
||||||
_vcs_unsupported tag #XXX
|
_vcs_unsupported tag #XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fonctions avancées de git
|
||||||
|
function git_list_branches() {
|
||||||
|
git for-each-ref refs/heads/ --format='%(refname:short)' | csort
|
||||||
|
}
|
||||||
|
function git_list_rbranches() {
|
||||||
|
git for-each-ref "refs/remotes/${1:-origin}/" --format='%(refname:short)' | csort
|
||||||
|
}
|
||||||
|
function git_get_branch() {
|
||||||
|
git rev-parse --abbrev-ref HEAD 2>/dev/null
|
||||||
|
}
|
||||||
|
function git_is_branch() {
|
||||||
|
[ "$(get_branch)" == "${1:-master}" ]
|
||||||
|
}
|
||||||
|
function git_has_remote() {
|
||||||
|
[ -n "$(git config --get remote.${1:-origin}.url)" ]
|
||||||
|
}
|
||||||
|
function git_track_branch() {
|
||||||
|
local branch="$1" origin="${2:-origin}"
|
||||||
|
[ -n "$branch" ] || return
|
||||||
|
git_has_remote "$origin" || return
|
||||||
|
[ "$(git config --get branch.$branch.remote)" == "$origin" ] && return
|
||||||
|
git branch -t --set-upstream "$branch" "$origin/$branch"
|
||||||
|
}
|
||||||
|
function git_check_cleancheckout() {
|
||||||
|
# vérifier qu'il n'y a pas de modification locales dans le dépôt
|
||||||
|
# correspondant au répertoire courant.
|
||||||
|
[ -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"
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Subversion
|
# Subversion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue