Skip to content

Conversation

@sanity
Copy link
Collaborator

@sanity sanity commented Oct 27, 2025

Summary

Adds a commit-msg hook that validates commit messages follow Conventional Commits format locally, preventing CI failures.

Problem

PR #2004 failed CI because the PR title used Fix: (capital F) instead of fix: (lowercase f). The Conventional Commits CI check only runs on GitHub, so there was no local feedback before pushing.

Solution

Added .githooks/commit-msg that validates commit messages locally before allowing the commit. This catches formatting issues (like capital letters in type) immediately.

Installation

Users can install the hook via:

cp .githooks/commit-msg .git/hooks/
chmod +x .git/hooks/commit-msg

Or configure git to use the hooks directory:

git config core.hooksPath .githooks

Tested

The hook correctly:

  • ✓ Blocks commits like Fix: message (capital F)
  • ✓ Allows commits like fix: message (lowercase f)
  • ✓ Validates all allowed types: feat, fix, docs, style, refactor, perf, test, build, ci
  • ✓ Supports scopes and breaking changes (fix(core)!: message)

Benefits

  • Prevents CI failures from incorrectly formatted commit messages
  • Immediate feedback during local development
  • Matches the CI check on GitHub PRs

[AI-assisted debugging and comment]

Adds a commit-msg hook that validates commit messages follow the
Conventional Commits format before allowing the commit.

This prevents commits with incorrectly formatted messages (e.g., 'Fix:'
instead of 'fix:') and ensures compatibility with our GitHub CI checks.

The hook is installed via:
  cp .githooks/commit-msg .git/hooks/
  chmod +x .git/hooks/commit-msg

Or configure git to use the hooks directory:
  git config core.hooksPath .githooks

[AI-assisted debugging and comment]
@sanity sanity added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit 330e12a Oct 27, 2025
10 checks passed
@sanity sanity deleted the build/add-commit-msg-hook branch October 27, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants