git-commit.plugin.zsh 592 B

123456789101112131415161718192021222324252627
  1. function _git_commit_register {
  2. if ! git config --global --get-all alias.$1 >/dev/null 2>&1; then
  3. git config --global alias.$1 '!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$1'(${scope}): ${@}"; else git commit -m "'$1': ${@}"; fi }; a'
  4. fi
  5. }
  6. local -a _git_commit_aliases
  7. _git_commit_aliases=(
  8. 'build'
  9. 'chore'
  10. 'ci'
  11. 'docs'
  12. 'feat'
  13. 'fix'
  14. 'perf'
  15. 'refactor'
  16. 'revert'
  17. 'style'
  18. 'test'
  19. )
  20. for _alias in "${_git_commit_aliases[@]}"; do
  21. _git_commit_register $_alias
  22. done
  23. unfunction _git_commit_register
  24. unset _alias