Closed vid553 closed 3 months ago
I looked into this. I got it working for a singe entry and for multiple entry.
Single entry:
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt
stages: [pre-commit]
exclude: scripts/.*
Multiple entry:
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
- id: shfmt
stages: [pre-commit]
exclude: |
(?x)^(
scripts/codechecker-diff.sh|
scripts/rpi-jlink-server/request_resource.sh
)$
Please test this on your end. If it work I will add above exact example into the documentation.
Keep in mind that exclude
must be valid regex syntax as it is directly parsed by Python's re
module.
Confirming that both examples work. Thank you.
@vid553 for added visibility: https://github.com/IRNAS/irnas-guidelines-docs/commit/df30141eafbfc959c1f21104ab2a4f410cfe9917
Context
It is often needed that multiple files are excluded from pre-commit checks. It may be that we want to skip all checks or only a specific hook for a specific file.
According to the docs, the exclude property accepts a regular expression, but I didn't manage to get it to work properly, it only worked for a single entry. It would be helpful to have some examples in the documentation.
Relevant links:
Required steps / Implementation details
Provide examples in the docs that show how to exclude multiple files / directories globally and how to exclude them from a specific tool (hook).
Definition of Done
Described feature is documented.