Let's say we have some hook for a tool like Black (formatter for Python). Let's say we upgrade the hook to a version of the tool that introduces significant changes to its behavior.
Ideally we would want to re-run the hook on all the files in the repository, not just the next batch of modified ones. Ideally we would detect this case automatically and perform the repo-wide run either as part of the upgrade or as part of CI validations. The rest of the time pre-commit's normal behavior (only checking modified files) is fine.
How can we best achieve the ideal scenario?
One solution that comes to mind is to wrap pre-commit autoupdate
, but as far as I can tell, that can only run all hooks on all files. It would be nice to select only the upgraded hooks.
In CI one solution is to trigger a job when the pre-commit file gets modified, but that also has issues:
- We still don't know which hook to run.
- We will trigger for changes to config as well as hook upgrades. This may or may not be desirable.