Skip to content

Commit 88f2a83

Browse files
authored
Update readme to add how to improve performance (#65)
* docs: add example to use files in pre-commmit * chore: bump pre-commit-hooks version * docs: revise readme.md * Update README.md
1 parent 753f2bb commit 88f2a83

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -10,11 +10,11 @@ repos:
1010
- id: check-toml
1111
- id: requirements-txt-fixer
1212
- repo: https://github.com/asottile/pyupgrade
13-
rev: v3.15.0
13+
rev: v3.20.0
1414
hooks:
1515
- id: pyupgrade
1616
- repo: https://github.com/pycqa/flake8
17-
rev: '7.0.0'
17+
rev: '7.2.0'
1818
hooks:
1919
- id: flake8
2020
args: [--max-line-length=120]

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ repos:
5757
args: [--checks=.clang-tidy, --version=16] # Specifies version
5858
```
5959

60+
> [!IMPORTANT]
61+
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:
62+
63+
64+
```yaml
65+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
66+
rev: v0.6.1
67+
hooks:
68+
- id: clang-format
69+
args: [--style=file, --version=16]
70+
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ # limit the scope
71+
- id: clang-tidy
72+
args: [--checks=.clang-tidy, --version=16]
73+
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$
74+
```
75+
76+
Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command:
77+
78+
```bash
79+
pre-commit run --files $(git diff --name-only)
80+
```
81+
82+
This approach ensures that only modified files are checked, further speeding up the linting process during development.
83+
6084
## Output
6185

6286
### clang-format Example

0 commit comments

Comments
 (0)