|
| 1 | +# Git Hooks |
| 2 | + |
| 3 | +This directory contains git hooks that enforce code quality and commit message standards. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +To install these hooks, run from the repository root: |
| 8 | + |
| 9 | +```bash |
| 10 | +# Install commit-msg hook |
| 11 | +cp .githooks/commit-msg .git/hooks/ |
| 12 | +chmod +x .git/hooks/commit-msg |
| 13 | + |
| 14 | +# Or configure git to use this hooks directory |
| 15 | +git config core.hooksPath .githooks |
| 16 | +``` |
| 17 | + |
| 18 | +## Available Hooks |
| 19 | + |
| 20 | +### commit-msg |
| 21 | + |
| 22 | +Validates that commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format. |
| 23 | + |
| 24 | +**Required format:** |
| 25 | +``` |
| 26 | +type(scope): description |
| 27 | +
|
| 28 | +[optional body] |
| 29 | +
|
| 30 | +[optional footer(s)] |
| 31 | +``` |
| 32 | + |
| 33 | +**Allowed types:** |
| 34 | +- `feat`: New feature |
| 35 | +- `fix`: Bug fix |
| 36 | +- `docs`: Documentation changes |
| 37 | +- `style`: Code style changes (formatting, etc.) |
| 38 | +- `refactor`: Code refactoring |
| 39 | +- `perf`: Performance improvements |
| 40 | +- `test`: Adding or modifying tests |
| 41 | +- `build`: Build system or dependency changes |
| 42 | +- `ci`: CI/CD changes |
| 43 | + |
| 44 | +**Examples:** |
| 45 | +```bash |
| 46 | +fix: resolve WebSocket connection timeout |
| 47 | +feat(network): add peer reputation scoring |
| 48 | +build(deps): bump tokio from 1.0 to 1.1 |
| 49 | +fix!: breaking change to API |
| 50 | +``` |
| 51 | + |
| 52 | +**Important:** |
| 53 | +- Type must be **lowercase** (e.g., `fix:` not `Fix:`) |
| 54 | +- This matches the CI check on GitHub PRs |
| 55 | +- Breaking changes can be indicated with `!` after the type |
| 56 | + |
| 57 | +### pre-commit |
| 58 | + |
| 59 | +The pre-commit hook (already installed in `.git/hooks/pre-commit`) checks: |
| 60 | +- Code formatting with `cargo fmt` |
| 61 | +- Clippy lints |
| 62 | +- Special TODO comments that block commits |
| 63 | +- Disabled tests using Claude |
| 64 | + |
| 65 | +**Note:** The pre-commit hook is specific to your local setup and is already installed by git hooks installation scripts. It's not included in this directory as it's environment-specific. |
| 66 | + |
| 67 | +## Why This Matters |
| 68 | + |
| 69 | +- **CI Compatibility**: Our GitHub Actions CI checks PR titles for Conventional Commits format |
| 70 | +- **Consistency**: Everyone uses the same commit message style |
| 71 | +- **Automation**: Makes it easier to generate changelogs and release notes |
| 72 | +- **Early Feedback**: Catch issues locally before pushing to GitHub |
0 commit comments