Skip to content

Commit b7fc13e

Browse files
committed
docs: describe passing args
1 parent 194edaf commit b7fc13e

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
A [`pre-commit`](https://pre-commit.com) hook to check commit messages for
44
[Conventional Commits](https://conventionalcommits.org) formatting.
55

6+
Works with Python >= 3.8.
7+
68
## Usage
79

810
Make sure `pre-commit` is [installed](https://pre-commit.com#install).
@@ -24,7 +26,7 @@ repos:
2426
hooks:
2527
- id: conventional-pre-commit
2628
stages: [commit-msg]
27-
args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]
29+
args: []
2830
```
2931
3032
Install the `pre-commit` script:
@@ -62,9 +64,15 @@ Example commit message fixing an issue:
6264
6365
fix: remove infinite loop
6466
65-
Optionally, include a scope in parentheses after the type for more context:
67+
Example commit with scope in parentheses after the type for more context:
6668
6769
fix(account): remove infinite loop
70+
71+
Example commit with a body:
72+
73+
fix: remove infinite loop
74+
75+
Additional information on the issue caused by the infinite loop
6876
```
6977

7078
Make a (conventional) commit :heavy_check_mark::
@@ -115,6 +123,40 @@ print(is_conventional("nope: this is not a conventional commit"))
115123
print(is_conventional("custom: this is a conventional commit", types=["custom"]))
116124
```
117125

126+
## Passing `args`
127+
128+
`conventional-pre-commit` supports a number of arguments to configure behavior:
129+
130+
```shell
131+
$ conventional-pre-commit -h
132+
usage: conventional-pre-commit [-h] [--force-scope] [--strict] [types ...] input
133+
134+
Check a git commit message for Conventional Commits formatting.
135+
136+
positional arguments:
137+
types Optional list of types to support
138+
input A file containing a git commit message
139+
140+
options:
141+
-h, --help show this help message and exit
142+
--force-scope Force commit to have scope defined.
143+
--strict Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.
144+
```
145+
146+
Supply arguments on the command-line, or via the pre-commit `hooks.args` property:
147+
148+
```yaml
149+
repos:
150+
- repo: https://github.com/compilerla/conventional-pre-commit
151+
rev: <git sha or tag>
152+
hooks:
153+
- id: conventional-pre-commit
154+
stages: [commit-msg]
155+
args: [--strict, --force-scope, feat, fix, chore, test, custom]
156+
```
157+
158+
**NOTE:** when using as a pre-commit hook, `input` is supplied automatically (with the current commit's message).
159+
118160
## Development
119161

120162
`conventional-pre-commit` comes with a [VS Code devcontainer](https://code.visualstudio.com/learn/develop-cloud/containers)

conventional_pre_commit/hook.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def main(argv=[]):
2424
"--force-scope", action="store_false", default=True, dest="optional_scope", help="Force commit to have scope defined."
2525
)
2626
parser.add_argument(
27-
"--strict", action="store_true", help="Force commit to strictly follow Conventional Commits formatting."
27+
"--strict",
28+
action="store_true",
29+
help="Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.",
2830
)
2931

3032
if len(argv) < 1:
@@ -80,7 +82,7 @@ def main(argv=[]):
8082
8183
fix(account): remove infinite loop
8284
83-
{Colors.YELLOW}Example commit with a body
85+
{Colors.YELLOW}Example commit with a body:{Colors.RESTORE}
8486
8587
fix: remove infinite loop
8688

0 commit comments

Comments
 (0)