I have a pre-commit hook running a local executable and I set the pass_filenames
to true. When there are 11 files to modify in the git staging area, the hook is called three times with different filename arguments each time. I would like the hook to be called only once with all filenames.
This is my hook:
repos:
- repo: local
hooks:
- id: ruff-format
name: ruff-format
entry: "bin/ruff-format"
language: script
pass_filenames: true
files: "src/python/|test/python/"
types: [python]
Can this be accomplished? Am I doing something wrong? Thank you.
you can never guarantee that they will happen in exactly one call because commands have an operating system dependent length limit
you can hint at pre-commit that your particular tool is not parallel safe via require_serial: true
. this has the side effect of batching as much as possible but again cannot guarantee a single call
disclaimer: I wrote pre-commit