Pre-commit hook lets commit not formatted code
You can easily bypass the pre-commit hook formatting check, by doing so:
- Stage unformatted code
- Format code (but don't stage again)
- Commit
The problem is, it's easy to do these steps by mistake — when you try to commit unformatted code it asks you to run cargo fmt --all
. And when you do, it's easy to forget that you have to stage changes again, before committing.
Maybe there is some safe way to run formatting checks on staged code?