commit-msg 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. #
  3. # An example hook script to check the commit log message.
  4. # Called by "git commit" with one argument, the name of the file
  5. # that has the commit message. The hook should exit with non-zero
  6. # status after issuing an appropriate message if it wants to stop the
  7. # commit. The hook is allowed to edit the commit message file.
  8. YELLOW="\e[93m"
  9. GREEN="\e[32m"
  10. RED="\e[31m"
  11. ENDCOLOR="\e[0m"
  12. printMessage() {
  13. printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
  14. }
  15. printSuccess() {
  16. printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
  17. }
  18. printError() {
  19. printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
  20. }
  21. printMessage "Running the AppFlowy commit-msg hook."
  22. # This example catches duplicate Signed-off-by lines.
  23. test "" = "$(grep '^Signed-off-by: ' "$1" |
  24. sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
  25. echo >&2 Duplicate Signed-off-by lines.
  26. exit 1
  27. }
  28. .githooks/gitlint \
  29. --msg-file=$1 \
  30. --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \
  31. --subject-maxlen=100 \
  32. --subject-minlen=10 \
  33. --body-regex=".*" \
  34. --body-maxlen=200 \
  35. --max-parents=1
  36. if [ $? -ne 0 ]
  37. then
  38. printError "Please fix your commit message to match AppFlowy coding standards"
  39. printError "https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/software-contributions/submitting-code/code-submission-guidelines#commit-message-guidelines"
  40. exit 1
  41. fi