diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d9f4dbf..06eae45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,11 +10,11 @@ repos: - id: check-toml - id: requirements-txt-fixer - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.20.0 hooks: - id: pyupgrade - repo: https://github.com/pycqa/flake8 - rev: '7.0.0' + rev: '7.2.0' hooks: - id: flake8 args: [--max-line-length=120] diff --git a/README.md b/README.md index c61bb1d..bb0ce9d 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,30 @@ repos: args: [--checks=.clang-tidy, --version=16] # Specifies version ``` +> [!IMPORTANT] +> 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: + + +```yaml +- repo: https://github.com/cpp-linter/cpp-linter-hooks + rev: v0.6.1 + hooks: + - id: clang-format + args: [--style=file, --version=16] + files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ # limit the scope + - id: clang-tidy + args: [--checks=.clang-tidy, --version=16] + files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ +``` + +Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command: + +```bash +pre-commit run --files $(git diff --name-only) +``` + +This approach ensures that only modified files are checked, further speeding up the linting process during development. + ## Output ### clang-format Example