blob: 724527d6f01f3f218ac941fbaf1d05e8dcb3a07e [file] [log] [blame]
Chris Kay1c8a4962020-12-09 14:35:46 +00001#!/bin/bash
2
3file="$1"
4type="$2"
5
6if [ -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"
28fi