prepare-commit-msg.cz 567 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. file="$1"
  3. type="$2"
  4. if [ -z "$type" ]; then # only run on new commits
  5. #
  6. # Save any commit message trailers generated by Git.
  7. #
  8. trailers=$(git interpret-trailers --parse "$file")
  9. #
  10. # Execute the Commitizen hook.
  11. #
  12. (exec < "/dev/tty" && npx --no-install git-cz --hook) || true
  13. #
  14. # Restore any trailers that Commitizen might have overwritten.
  15. #
  16. printf "\n" >> "$file"
  17. while IFS= read -r trailer; do
  18. git interpret-trailers --in-place --trailer "$trailer" "$file"
  19. done <<< "$trailers"
  20. fi