|
| 1 | +# Commit Message Convention |
| 2 | + |
| 3 | +This project uses a commit message convention to automatically determine version bumps and generate changelogs. |
| 4 | + |
| 5 | +## Format |
| 6 | + |
| 7 | +All commit messages must follow this format: |
| 8 | + |
| 9 | +``` |
| 10 | +<type>[optional scope]: <description> |
| 11 | +``` |
| 12 | + |
| 13 | +## Commit Types |
| 14 | + |
| 15 | +### Version Bumps |
| 16 | + |
| 17 | +These commit types will trigger a new release: |
| 18 | + |
| 19 | +| Type | Version Bump | Description | Example | |
| 20 | +| --------------------------- | ----------------- | ------------------------------ | --------------------------------- | |
| 21 | +| `feat:`, `feature:`, `add:` | **Minor** (0.X.0) | New features or additions | `feat: Add user authentication` | |
| 22 | +| `fix:`, `bug:` | **Patch** (0.0.X) | Bug fixes | `fix: Resolve login issue` | |
| 23 | +| `update:`, `refactor:` | **Patch** (0.0.X) | Code improvements | `refactor: Simplify API client` | |
| 24 | +| `improve:`, `perf:` | **Patch** (0.0.X) | Performance improvements | `perf: Optimize database queries` | |
| 25 | +| `breaking:`, `major:` | **Major** (X.0.0) | Breaking changes | `breaking: Remove deprecated API` | |
| 26 | +| `<type>!:` | **Major** (X.0.0) | Breaking change (conventional) | `feat!: Redesign authentication` | |
| 27 | + |
| 28 | +### No Version Bump |
| 29 | + |
| 30 | +These commit types will NOT trigger a release: |
| 31 | + |
| 32 | +| Type | Description | Example | |
| 33 | +| ----------------- | ----------------------- | ------------------------------ | |
| 34 | +| `docs:`, `doc:` | Documentation changes | `docs: Update README` | |
| 35 | +| `test:`, `tests:` | Test changes only | `test: Add integration tests` | |
| 36 | +| `chore:` | Maintenance tasks | `chore: Update dependencies` | |
| 37 | +| `build:` | Build system changes | `build: Update webpack config` | |
| 38 | +| `ci:` | CI/CD changes | `ci: Add new workflow step` | |
| 39 | +| `style:` | Code style/formatting | `style: Run prettier` | |
| 40 | +| `revert:` | Revert previous commits | `revert: Revert feature X` | |
| 41 | + |
| 42 | +## Scopes (Optional) |
| 43 | + |
| 44 | +You can add a scope to provide more context: |
| 45 | + |
| 46 | +``` |
| 47 | +feat(auth): Add OAuth support |
| 48 | +fix(api): Resolve timeout issue |
| 49 | +chore(deps): Update packages |
| 50 | +``` |
| 51 | + |
| 52 | +## Examples |
| 53 | + |
| 54 | +### Good Commit Messages |
| 55 | + |
| 56 | +``` |
| 57 | +feat: Add dark mode toggle |
| 58 | +fix(ui): Resolve button alignment issue |
| 59 | +docs: Update installation instructions |
| 60 | +chore(deps): Bump lodash from 4.17.19 to 4.17.21 |
| 61 | +refactor: Extract validation logic |
| 62 | +perf: Optimize image loading |
| 63 | +breaking: Remove support for Node 12 |
| 64 | +build: Update webpack to v5 |
| 65 | +ci: Add code coverage reporting |
| 66 | +style: Apply prettier formatting |
| 67 | +revert: Revert "Add experimental feature" |
| 68 | +``` |
| 69 | + |
| 70 | +### Bad Commit Messages (Will be Rejected) |
| 71 | + |
| 72 | +``` |
| 73 | +Update files |
| 74 | +WIP |
| 75 | +quick fix |
| 76 | +Fixed bug |
| 77 | +Added feature |
| 78 | +``` |
| 79 | + |
| 80 | +## Automatic Validation |
| 81 | + |
| 82 | +Commit messages are validated in two places: |
| 83 | + |
| 84 | +1. **Locally (git hook)**: When you commit, a git hook validates your message. If invalid, you'll see a helpful error message with examples. |
| 85 | +2. **In CI (GitHub Actions)**: All commits in a pull request are validated using the same hook. The PR will fail if any commits don't follow the convention. |
| 86 | + |
| 87 | +This ensures everyone follows the same standards, whether they have git hooks installed or not. |
| 88 | + |
| 89 | +## Version Calculation |
| 90 | + |
| 91 | +- Pull requests show a comment indicating what version bump will occur |
| 92 | +- When merged to main, the version is automatically calculated and released |
| 93 | +- Only commits with releasable types trigger new versions |
| 94 | + |
| 95 | +## Special Cases |
| 96 | + |
| 97 | +- Merge commits are automatically skipped from validation |
| 98 | +- `[skip ci]` commits (auto-generated) are skipped from validation |
| 99 | +- Only non-releasable changes (docs/test/chore/build/ci/style/revert) won't trigger a release |
| 100 | +- If a PR contains both releasable and non-releasable commits, a release will be triggered |
| 101 | +- Dependabot is configured to use `chore(deps):` format automatically |
0 commit comments