#!/bin/sh # Conventional Commits check for repos without Node (R packages, Shiny apps). # Install from R: usethis::use_git_hook("commit-msg", readLines("commit-msg")) first_line=$(head -n 1 "$1") case "$first_line" in Merge\ *|Revert\ *|fixup!\ *|squash!\ *) exit 0 ;; esac pattern='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9_./-]+\))?!?: .+' if printf '%s' "$first_line" | grep -Eq "$pattern"; then exit 0 fi echo "✖ Commit message is not a Conventional Commit:" >&2 echo " $first_line" >&2 echo " Expected: (): " >&2 echo " e.g. feat(read_adsl): support SAS transport files" >&2 echo " fix: handle empty data in km_plot()" >&2 exit 1