https://github.com/aliymn/conventional-commits-check
Once added, the hook runs on every commit, checks messages against Conventional Commits rules, adds emojis, and blocks non-compliant commits.
https://github.com/aliymn/conventional-commits-check
commit conventional-commits pre-commit pre-commit-hook python python3
Last synced: 8 months ago
JSON representation
Once added, the hook runs on every commit, checks messages against Conventional Commits rules, adds emojis, and blocks non-compliant commits.
- Host: GitHub
- URL: https://github.com/aliymn/conventional-commits-check
- Owner: AliYmn
- License: mit
- Created: 2023-03-26T21:03:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T11:49:21.000Z (over 1 year ago)
- Last Synced: 2025-01-30T07:36:11.744Z (over 1 year ago)
- Topics: commit, conventional-commits, pre-commit, pre-commit-hook, python, python3
- Language: Python
- Homepage:
- Size: 799 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# π Conventional Commits Check









`conventional-commits-check` is a powerful and easy-to-use Python pre-commit hook that helps enforce [Conventional Commits](https://www.conventionalcommits.org/) rules on your commit messages. It supports adding relevant emojis based on your commit types to enhance readability and bring some fun to your commit history! π
## π What are Conventional Commits?
Conventional Commits provide a lightweight convention for creating a clear and explicit commit history. By using this hook, you'll ensure that your commit messages follow this convention, making your versioning easier to manage and your collaboration more seamless.
## π‘ Features
- β
Enforces Conventional Commits rules on your commit messages.
- π¨ Optionally adds context-specific emojis to the start of commit messages.
- π Blocks commits that do not conform to the Conventional Commits standard.
- π§ Allows for **custom commit types** and **custom emojis** via configuration.
- π **Auto-Merge Commit Handling**: Automatically formats auto-merge commit messages to follow a consistent style.
## π Auto-Merge Commit Handling
The `conventional-commits-check` tool includes functionality to handle auto-merge commit messages. When a commit message matches the pattern "Merge branch '...' into '...'", it is automatically reformatted to a more consistent style, such as "merge: branch '...' into '...'". If emojis are enabled, a π emoji is prepended to the message. This feature ensures that even auto-generated commit messages maintain a clean and readable format.
## π§ Customization
You can customize the commit types and their associated emojis by modifying the `commit_types.py` and `commits_check_config.yaml` files. These files allow you to define additional commit types and specify emojis for each type.
### Example : [`commit_types.py`](https://github.com/AliYmn/conventional-commits-check/blob/master/conventional_commits_check/commit_types.py)
```python
commit_types = {
"access": {
"description": "Improve accessibility.",
"emoji": "βΏοΈ"
},
"analytics": {
"description": "Add or update analytics or track code.",
"emoji": "π"
},
"animation": {
"description": "Add or update animations and transitions.",
"emoji": "π«"
},
"arch": {
"description": "Make architectural changes.",
"emoji": "ποΈ"
},
"assets": {
"description": "Add or update assets.",
"emoji": "π±"
},
"beer": {
"description": "Write code drunkenly.",
"emoji": "π»"
},
# ... more commit types ...
}
```
### Customizing Existing Emojis
You can also modify the emojis for existing commit types by updating the `commits_check_config.yaml`:
```yaml
additional_commit_types:
feat:
description: Introduce new features.
emoji: π
fix:
description: Fix a bug.
emoji: π οΈ
```
## βοΈ Installation
To add `conventional-commits-check` to your project, follow these steps:
1. **Update your `.pre-commit-config.yaml`:**
In your projectβs root directory, add the following:
```yaml
repos:
- repo: https://github.com/AliYmn/conventional-commits-check
rev: v2.9.0 # Use the latest release version
hooks:
- id: conventional-commits-check
stages: [commit-msg]
args: ["--emoji-disabled"] # Use this argument to disable emojis
```
2. **Install the pre-commit hook:**
```bash
pre-commit install --hook-type commit-msg -f
```
3. **Install the `conventional-commits-check` package:**
```bash
pip install -U conventional-commits-check
```
4. **Optional:** Update the pre-commit package:
```bash
pre-commit autoupdate
```
## π Usage
Once the hook is added, it will automatically run each time you make a commit. The hook checks your commit message against Conventional Commits rules, optionally adds the appropriate emoji, and prevents non-conforming commits.
## π¨βπ» Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to enhance `conventional-commits-check`. Letβs make commits fun and consistent! π
## π License
This project is licensed under the [MIT License](LICENSE).
---
Enhance your workflow and bring some life to your commits with `conventional-commits-check`! πβ¨π