#!/usr/bin/env bash # Checks a commit message (CONTRIBUTING.md "Commit style"): Conventional Commits format, checked by # commitizen (dev/check-commit-msg.sh); and, if you opted in with # `git config frame-tweaks.refuseToolTrailers true`, no tool attribution lines (dev/check-trailers.sh). # Enable: dev/install-hooks.sh set -euo pipefail msg_file="${1:?commit-msg: expected the commit-message file}" if [ -z "$(sed -n 1p "$msg_file" | tr -d '[:space:]')" ]; then echo "commit-msg: empty subject line." >&2 exit 1 fi if [ "$(git config --bool frame-tweaks.refuseToolTrailers)" = true ] && ! "$(git rev-parse --show-toplevel)/dev/check-trailers.sh" "$msg_file"; then echo "commit-msg: remove the tool attribution line(s) above (you set frame-tweaks.refuseToolTrailers)." >&2 exit 1 fi if ! "$(git rev-parse --show-toplevel)/dev/check-commit-msg.sh" "$msg_file"; then echo "commit-msg: start the subject with a type, e.g. \"fix(arrowpad): ...\" or \"docs: ...\" (.cz.toml)." >&2 exit 1 fi