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