mattlqx / pre-commit-search-and-replace

Plugin for pre-commit for arbitrary search and replace on committed files.
MIT License
12 stars 7 forks source link

Is there a way to only check the diff? #9

Closed mattdeutsch closed 2 years ago

mattdeutsch commented 3 years ago

Currently, running this hook on a file you've changed some of will run the search-and-replace functionality on the whole file. It would be preferable to have it only check the additions that are in the diff. Is there a toggle to have it only check the diff that I've missed?

mattlqx commented 3 years ago

Hey, no, it's not a feature. The script just gets changed filenames passed to it by pre-commit. It's much the same way that linters typically operate on the whole file though, not just the bits that have changed. It'd probably be possible to do a git diff and find line ranges that were changed, but it does increase the complexity a bit.

mattdeutsch commented 3 years ago

Unfortunate - thanks for the quick response!