@eqworks/commit-watch
v0.2.0
Published
A CLI to gatekeep commit messages that do not conform to conventions.
Downloads
158
Readme
commit-watch
A CLI to gatekeep commit messages that do not conform to conventions.
Installation
If you have npx
available, you can directly use it without explicit installation:
% npx @eqworks/commit-watch --help
Otherwise, or when explicitly local installation is needed:
% npm i -g @eqworks/commit-watch
% # or
% yarn global add @eqworks/commit-watch
Then:
% commit-watch --help
Usage
This CLI is designed to work in any git repository to exit with code 1 (process.exit(1)
) when there are any mismatches of the commit message (subject line only) against the convention category[/sub-category] - subject title
or in RegEx as /(?<cat>\S+?)(\/(?<t2>\S+))? - (?<title>.*)/
:
% commit-watch -b origin/master -v
⚠ 6/9 do not match pattern "category[/sub-category] - subject title"
✖ define APIError
✖ fix /readme to reflect changes in selectUser
✖ remove unnecessary await
✖ refactor selectUser to return user || undefined
✖ PR fixes, throws APIError
✖ check if user exists, won't send opt email if user unknown
✓ users - make getUsers async, await db query
✓ login - throw error on /users endpoints when user not found
✓ login - misc PR changes
and the exit code:
% echo $?
1
To use it in an automated/CI environment such as GitHub Actions, check out the dogfood
job in this workflow, essentially by pinning down the --base
and --head
git refs (in this case, through the given ${{ github }}
context):
commit-watch -b ${{ github.event.pull_request.base.sha }} -h ${{ github.event.pull_request.head.sha }} -v