Is there a way to tell the pre-commit (pre-commit.com) to apply fixes just to the modified text instead of the entire files touched? We want to set up spellchecking (using typos) on our API models, but some were already released. Thus fixing errors in the released interfaces is undesirable. Only newly added changes should be spellchecked.
Edit:
./git/hooks/pre-commit
has pretty much unmodified content generated by pre-commit install
.
#!/usr/bin/env bash
# Get python from environment:
INSTALL_PYTHON=$(command -v python3 || command -v python)
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")
if [ -x "$INSTALL_PYTHON" ]; then
exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
exec pre-commit "${ARGS[@]}"
else
echo "'pre-commit' not found, install it with 'pip install pre-commit'!" 1>&2
exit 1
fi
there isn't. pre-commit (and almost every tool that plugs into it) operates on files
disclaimer: I wrote pre-commit