New pr-comments and base-merge Features Added to Commit Check for Enhanced Pull Request Validation
The latest release of Commit Check introduces two new capabilities—pr-comments, which automatically posts check results as Pull Request comments, and base-merge, which verifies that a branch is rebased onto the target branch—thereby improving PR review efficiency and CI pipeline enforcement.
What is Commit Check
If you are not familiar with Commit Check, it is a free, powerful tool that enforces commit metadata standards such as commit messages, branch naming, author name/email, and sign‑off, with fully customizable error messages and suggestions.
It serves as an open‑source alternative to GitHub Enterprise metadata restrictions and the commercial Bitbucket plugin Yet Another Commit Checker, offering the best free solution for Conventional Commits and Branch support.
New Features
1. pr-comments: Automatically Add Check Results to Pull Requests
In team development, PRs are the main entry point for code review. The pr-comments feature posts the results of commit‑check directly as comments on the PR after the CI/CD pipeline runs, eliminating the need to view separate log files.
Developers can see success or failure messages directly in the PR conversation, making it easier to locate issues quickly.
Example screenshots:
pr‑comments success
pr‑comments failure
Note: pr-comments only works with commit-check-action .
2. base-merge: Ensure Branch Is Based on Target Branch
This option checks whether a PR branch has been rebased onto a specified target branch (e.g., main or master ).
Automatically verifies that the current branch is based on the target branch.
If the base is incorrect, commit‑check fails the CI pipeline and provides a clear error message.
Note: base-merge is supported by both commit-check and commit-check-action .
Configuration
Using Default Configuration
If no .commit-check.yml file is present, Commit Check uses its default settings, enforcing Conventional Commits for messages and Conventional Branch rules for branch names.
Custom Configuration
To customize, edit the .commit-check.yml file. Example configuration:
checks:
- check: message
regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)|(Merge).*|(fixup!.*)'
error: "The commit message should be structured as follows:\n\n
[optional scope]:
\n [optional body]\n [optional footer(s)]\n\n More details please refer to https://www.conventionalcommits.org"
suggest: Please check your commit message against the above regex.
- check: branch
regex: '^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)'
error: "Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/"
suggest: Run command `git checkout -b type/branch_name`
- check: author_name
regex: '^[A-Za-z ,.\\'-]+$|.*(\[bot])'
error: The committer name seems invalid
suggest: Run command `git config user.name "Your Name"`
- check: author_email
regex: '^.+@.+$'
error: The committer email seems invalid
suggest: Run command `git config user.email [email protected]`
- check: commit_signoff
regex: 'Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>'
error: Signed-off-by not found in latest commit
suggest: Run command `git commit -m "conventional commit message" --signoff`
- check: merge_base
regex: 'main' # it can be master, develop, devel etc. based on your project.
error: Current branch is not rebased onto target branch
suggest: Ensure your branch is rebased with the target branchUsage
As a GitHub Action
name: Commit Check
on:
push:
pull_request:
branches: 'main'
jobs:
commit-check:
runs-on: ubuntu-latest
permissions:
# use permissions because of pr-comments
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit
fetch-depth: 0 # required for merge‑base check
- uses: commit-check/commit-check-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for pr‑comments
with:
message: true
branch: true
author-name: true
author-email: true
commit-signoff: true
merge-base: false
job-summary: true
pr-comments: ${{ github.event_name == 'pull_request' }}As a pre‑commit Hook
Add the following to .pre-commit-config.yaml :
- repo: https://github.com/commit-check/commit-check
rev: the tag or revision
hooks:
- id: check-message # requires hook prepare-commit-msg
- id: check-branch
- id: check-author-name
- id: check-author-email
- id: check-commit-signoff
- id: check-merge-base # requires downloading all git historyAs a CLI Tool
Install from PyPI:
pip install commit-check
# example
commit-check --message --branch --author-name --author-email --commit-signoff --merge-baseFor more details, see the README and open issues on GitHub.
References
commit-check-action: https://github.com/commit-check/commit-check-action
commit-check: https://github.com/commit-check/commit-check
GitHub Enterprise metadata restrictions: https://docs.github.com/en/[email protected]/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#metadata-restrictions
Yet Another Commit Checker: https://marketplace.atlassian.com/apps/1211854/yet-another-commit-checker?tab=overview&hosting=datacenter
README: https://github.com/commit-check/commit-check
GitHub Issues: https://github.com/commit-check/commit-check/issues
DevOps Engineer
DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.