https://github.com/boidolr/pre-commit-msg
Automagically prefix and format commit messages when committing
https://github.com/boidolr/pre-commit-msg
git git-hooks pre-commit
Last synced: 4 months ago
JSON representation
Automagically prefix and format commit messages when committing
- Host: GitHub
- URL: https://github.com/boidolr/pre-commit-msg
- Owner: boidolr
- License: mit
- Created: 2022-01-12T18:57:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-26T03:29:23.000Z (about 1 year ago)
- Last Synced: 2025-05-26T04:51:17.634Z (about 1 year ago)
- Topics: git, git-hooks, pre-commit
- Language: Python
- Homepage:
- Size: 363 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
pre-commit-msg
[](https://github.com/boidolr/pre-commit-msg/tags)

[](https://github.com/boidolr/pre-commit-msg/actions/workflows/continous-integration.yml)
[](https://github.com/pre-commit/pre-commit)
================
A collection of prepare message and commit message git hooks for use with the [pre-commit](https://github.com/pre-commit/pre-commit) framework. For details see the list of available hooks below.
## Using pre-commit-msg with pre-commit
Add this to your `.pre-commit-config.yaml`:
```
- repo: https://github.com/boidolr/pre-commit-msg
rev: v1.4.0 # Use the ref you want to point at
hooks:
- id: format-message
# - id: ...
```
For an extended example see [`.pre-commit-config.yaml`](.pre-commit-config.yaml).
## Available hooks
- **`prepare-message`**: Change commit messages to include a prefix.
- `--ignore-branch` will lead to the branch not being checked.
- `--pattern` can be used to change the feature branch pattern to take the message prefix from.
Needs to match with `--prefix-pattern`. Defaults to `feature/(\w+-\d+)`.
- `--prefix-pattern` should match the prefix of the message to normalize it.
Needs to match with `--pattern`. Defaults to `^\s*\w+-\d+\s*:`
- **`format-message`**: Ensure commit message conforms to format of headline followed by two empty lines.
- `--capitalize` if the subject line should be capitalized. Other lines remain unchanged.