Skip to content

Commit 876356a

Browse files
Present alternative pygrep hooks in README.
* README.md
1 parent f6d160a commit 876356a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ Revisions are considered frozen when a _hex object name_ is used. That is a hash
4747

4848
The rules `u` and `f` cannot be enabled together.
4949

50+
## Alternatives
51+
52+
You can also implement rules `f`, `u`, `m`, `e` with a more lightweight and faster pygrep hook.
53+
That is a simple check against a regular expression:
54+
55+
<!-- prettier-ignore-start -->
56+
```yaml
57+
- repo: local
58+
hooks:
59+
- id: rev-frozen
60+
name: revs must be frozen
61+
entry: "\\brev: (?!['\"]?[a-f0-9]{40})"
62+
language: pygrep
63+
files: '\.pre-commit-config.yaml'
64+
- id: rev-frozen-comment
65+
name: frozen revs must have a corresponding comment
66+
entry: "\\brev: (['\"]?)[a-f0-9]{40}\\1(?!\\s*# frozen: \\S+)"
67+
language: pygrep
68+
files: '\.pre-commit-config.yaml'
69+
- id: rev-unfrozen
70+
name: revs may not be frozen
71+
entry: "\\brev: ['\"]?[a-f0-9]{40}"
72+
language: pygrep
73+
files: '\.pre-commit-config.yaml'
74+
- id: rev-unfrozen-comment
75+
name: unfrozen revs may not have a contradicting comment
76+
entry: "\\brev: (?!(['\"]?)[a-f0-9]{40}\\1).*\\s*# frozen:"
77+
language: pygrep
78+
files: '\.pre-commit-config.yaml'
79+
```
80+
<!-- prettier-ignore-end -->
81+
5082
## Versioning
5183

5284
In adherence to [semver](https://semver.org/) the following rules determine compatibility between different versions of this hook.

0 commit comments

Comments
 (0)