feat(git-commit): add `-a | --attention` flag
Refactor function as well to reduce flaws and increase stability
Closes #12234
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diff
1diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh
2index 207c37e2175aecd06142aec2d0a8525b4dcc787f..7ad349735350f6bce6634f484e2a6f2604ab2f67 100644
3--- a/plugins/git-commit/git-commit.plugin.zsh
4+++ b/plugins/git-commit/git-commit.plugin.zsh
5@@ -28,7 +28,30 @@ for _type in "${_git_commit_aliases[@]}"; do
6 *) _alias=$_type ;;
7 esac
8 9- 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'
10+ local _func='!a() {
11+local _scope _attention _message
12+while [ $# -ne 0 ]; do
13+case $1 in
14+ -s | --scope )
15+ if [ -z $2 ]; then
16+ echo "Missing scope!"
17+ return 1
18+ fi
19+ _scope="$2"
20+ shift 2
21+ ;;
22+ -a | --attention )
23+ _attention="!"
24+ shift 1
25+ ;;
26+ * )
27+ _message+=" $1"
28+ shift 1
29+ ;;
30+esac
31+done
32+git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
33+}; a'
3435 git config --global alias.$_alias "$_func"
36 done