Examples & Use Cases
Conventional Commits
Enforce Conventional Commits format in your PRs
This example shows how to enforce the Conventional Commits format in your pull requests, ensuring a consistent and meaningful commit history.
Complete Configuration
How It Works
This ruleset:
- Triggers when a PR is opened, edited, or synchronized
- Validates that the PR title follows the Conventional Commits format
- Validates that all commit messages follow the Conventional Commits format (ignoring merge commits)
- Adds a “conventional-format” label when validations pass
- Comments with guidance when validations fail
Key Components
Title Validation
The title validator ensures the PR title follows the format type(scope): description
:
Commit Validation
The commit validator ensures all commit messages follow the same format:
Setting ignore_merge_commits: true
prevents validation failures on automatically generated merge commits.
Feedback Mechanism
When validations fail, a detailed comment is added to guide contributors:
Customization Options
You can customize this ruleset in several ways:
Modified Type List
If you want to use a different set of types:
Require Scope
If you want to make the scope mandatory:
First Commit Only
For workflows that squash commits, validate only the first commit:
Implementation Tips
- Provide Templates: Create PR templates that include the conventional format
- Setup Git Hooks: Use tools like commitlint locally
- Educate Contributors: Link to the Conventional Commits documentation in your README
- Start Simple: Begin with basic validation and gradually add complexity
Benefits
- Automated Changelogs: Tools can parse conventional commits to generate changelogs
- Clear Intent: The commit type instantly communicates the purpose of a change
- Semantic Versioning: Types like “feat” and “fix” can trigger appropriate version bumps
- Better History: Makes your repository history more meaningful and navigable