fix(git-commit)!: allow alias update
BREAKING CHANGE: Prior to this commit, git aliases were not being
updated after every update of oh-my-zsh. In case you were using
git-commit plugin before this commit, please remove your git aliases to
proceed.
Diff
1diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh
2index 3f0c2121dda4e13c20165e882dca5af4eeb06987..207c37e2175aecd06142aec2d0a8525b4dcc787f 100644
3--- a/plugins/git-commit/git-commit.plugin.zsh
4+++ b/plugins/git-commit/git-commit.plugin.zsh
5@@ -1,3 +1,8 @@
6+if git config --global --get-all alias.$_alias >/dev/null 2>&1 \
7+ && ! git config --global --get-all oh-my-zsh.git-commit-alias >/dev/null 2>&1; then
8+ return
9+fi
10+
11 local -a _git_commit_aliases
12 _git_commit_aliases=(
13 'build'
14@@ -14,19 +19,18 @@ _git_commit_aliases=(
15 'wip'
16 )
1718-local alias type
19-for type in "${_git_commit_aliases[@]}"; do
20+local _alias _type
21+for _type in "${_git_commit_aliases[@]}"; do
22 # an alias can't be named "revert" because the git command takes precedence
23 # https://stackoverflow.com/a/3538791
24- case "$type" in
25- revert) alias=rev ;;
26- *) alias=$type ;;
27+ case "$_type" in
28+ revert) _alias=rev ;;
29+ *) _alias=$_type ;;
30 esac
3132- local func='!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$type'(${scope}): ${@}"; else git commit -m "'$type': ${@}"; fi }; a'
33- if ! git config --global --get-all alias.${alias} >/dev/null 2>&1; then
34- git config --global alias.${alias} "$func"
35- fi
36+ local _func='!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$type'(${scope}): ${@}"; else git commit -m "'$type': ${@}"; fi }; a'
37+
38+ git config --global alias.$_alias "$_func"
39 done
4041-unset _git_commit_aliases alias type func
42+git config --global oh-my-zsh.git-commit-alias "true"