Looks like you need to have a pre-commit version 1.21.0+ for that files:
key to work:
https://pre-commit.com/#top_level-files
I tested it here and it seems to be operating correctly (I added some files with violations, so the action correctly is failing): add readme · noahp/test-precommit-file-key@891ba35 · GitHub
For clang-format
, I’ve updated the article with some hints (see PR here), but it’s probably best to add a .clang-format
file to the repo base- that way running clang-format
outside of pre-commit
will have the same behavior (the alternative would be to list out the options in the hook, but then it would only impact pre-commit
's invocation of clang-format
).
You can generate a config with clang-format --style=Google --dump-config > .clang-format
, but note that that will output ALL the options set by that config; you might want to start with a BasedOnStyle
and override only the options you need, to keep the .clang-format
file simpler (Clang-Format Style Options — Clang 13 documentation)