From 8e8ec1348b3d4ae5fa156e26c07040ade461c83a Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 6 Sep 2023 10:54:11 +0200 Subject: [PATCH] fix(git-commit): avoid conflict with `aliases` var Closes #11876 --- plugins/git-commit/git-commit.plugin.zsh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh index 70d541f21..2ac8aa5f4 100644 --- a/plugins/git-commit/git-commit.plugin.zsh +++ b/plugins/git-commit/git-commit.plugin.zsh @@ -1,10 +1,11 @@ -_register() { - if ! git config --global --get-all alias.$1 &>/dev/null; then +function _git_commit_register { + if ! git config --global --get-all alias.$1 >/dev/null 2>&1; then git config --global alias.$1 '!a() { if [[ "$1" == "-s" || "$1" == "--scope" ]]; then git commit -m "'$1'(${2}): ${@:3}"; else git commit -m "'$1': ${@}"; fi }; a' fi } -aliases=( +local -a _git_commit_aliases +_git_commit_aliases=( 'build' 'chore' 'ci' @@ -18,6 +19,9 @@ aliases=( 'test' ) -for alias in "${aliases[@]}"; do - _register $alias -done \ No newline at end of file +for _alias in "${_git_commit_aliases[@]}"; do + _git_commit_register $_alias +done + +unfunction _git_commit_register +unset _alias