Configuration
Must be set to
"commit"
Regex pattern(s) that commit messages should match
Regex pattern(s) for commit messages to ignore
Skip validation for merge commits (starting with “Merge ”)
Only validate the first commit in the PR
Only validate the last commit in the PR
Custom message to display when validation fails
Basic Usage
Examples
Conventional Commits Format
Validate that commit messages follow the Conventional Commits format:Issue Reference Required
Ensure commits reference an issue number:Validate Only the Last Commit
For squash-and-merge workflows, you might only care about the last commit:Ignore Certain Commit Patterns
Skip validation for certain types of commits:Pattern Matching
The Commit Validator uses JavaScript regular expressions for pattern matching. When specifying patterns, remember:- Patterns are case-sensitive by default
- Some characters need to be escaped with a backslash (
\
) - In YAML, backslashes need to be double escaped (
\\
)
i
flag: "/pattern/i"
How It Works
1
Retrieve Commits
The validator fetches all commits in the PR from the GitHub API
2
Filter Commits
Applies filtering based on
ignore_merge_commits
, first_only
, or last_only
settings3
Check Patterns
For each commit, checks if the message matches required patterns and doesn’t match ignored patterns
4
Return Result
Returns a validation result with status (pass, fail, or error) and a message listing any non-conforming commits
Complete Rule Example
Best Practices
Enable
ignore_merge_commits
to avoid validation errors on automated merge commitsProvide helpful error messages explaining the expected format
Consider combining with the title validator for a consistent history
For squash-and-merge workflows, use
last_only: true
Complex validation rules may be frustrating for contributors; consider providing commit message templates