aboutsummaryrefslogtreecommitdiff
path: root/.husky/prepare-commit-msg.cz
blob: 724527d6f01f3f218ac941fbaf1d05e8dcb3a07e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

file="$1"
type="$2"

if [ -z "$type" ]; then # only run on new commits
    #
    # Save any commit message trailers generated by Git.
    #

    trailers=$(git interpret-trailers --parse "$file")

    #
    # Execute the Commitizen hook.
    #

    (exec < "/dev/tty" && npx --no-install git-cz --hook) || true

    #
    # Restore any trailers that Commitizen might have overwritten.
    #

    printf "\n" >> "$file"

    while IFS= read -r trailer; do
        git interpret-trailers --in-place --trailer "$trailer" "$file"
    done <<< "$trailers"
fi