Files
PaperlessMCP/.githooks/commit-msg
T
Barry Walker 39768fdd45 ci: add local git hook for conventional commit validation
Run `git config core.hooksPath .githooks` to enable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 18:28:31 -05:00

38 lines
978 B
Bash
Executable File

#!/bin/sh
# Conventional Commits validation hook
# https://www.conventionalcommits.org/
commit_msg_file="$1"
commit_msg=$(cat "$commit_msg_file")
# Skip merge commits
if echo "$commit_msg" | grep -qE "^Merge "; then
exit 0
fi
# Conventional commit pattern
# type(scope)?: description
# type!: breaking change
pattern="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?\!?: .{1,}"
if ! echo "$commit_msg" | grep -qE "$pattern"; then
echo ""
echo "ERROR: Commit message does not follow Conventional Commits format."
echo ""
echo "Your message:"
echo " $commit_msg"
echo ""
echo "Expected format:"
echo " type(scope)?: description"
echo ""
echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
echo ""
echo "Examples:"
echo " feat: add user authentication"
echo " fix(api): handle null response"
echo " docs: update README"
echo " feat!: breaking change to API"
echo ""
exit 1
fi