Skip to content

ENH: Add pre-commit hook to enforce ITK commit message conventions#303

Open
hjmjohnson wants to merge 1 commit intomainfrom
enforce-itk-commit-conventions
Open

ENH: Add pre-commit hook to enforce ITK commit message conventions#303
hjmjohnson wants to merge 1 commit intomainfrom
enforce-itk-commit-conventions

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Summary

  • Adds a commit-msg pre-commit hook that validates commit messages follow the ITK convention: PREFIX: Description (e.g., ENH: Add new feature)
  • Valid prefixes: BUG:, COMP:, DOC:, ENH:, PERF:, STYLE:
  • Merge commits are automatically exempt
  • Provides a clear error message with examples when validation fails

Test plan

  • Install pre-commit: pip install pre-commit && pre-commit install --hook-type commit-msg
  • Verify a valid commit like ENH: Test feature is accepted
  • Verify an invalid commit like add thing is rejected with a helpful error
  • Verify merge commits pass without validation

🤖 Generated with Claude Code

Add pre-commit hooks in Utilities/Hooks/ matching ITK's directory
structure and commit message enforcement:

- prepare-commit-msg: Inserts ITK prefix instructions into the commit
  message editor so developers see valid prefixes while composing.

- kw-commit-msg.py: Validates commit messages with the same rules as
  upstream ITK: prefix check (BUG/COMP/DOC/ENH/PERF/STYLE/WIP),
  subject line max 78 chars, no leading/trailing whitespace, empty
  second line, and Merge/Revert exemptions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hjmjohnson hjmjohnson force-pushed the enforce-itk-commit-conventions branch from a476e37 to a8b19f3 Compare April 3, 2026 20:51
@hjmjohnson hjmjohnson requested a review from dzenanz April 3, 2026 23:13
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on a glance. Preferably someone else should review too.

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