git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

Specifying refs for use in CI?

Open blalor opened this issue 4 months ago • 2 comments

From https://pre-commit.com/#usage-in-continuous-integration:

pre-commit can also be used as a tool for continuous integration. For instance, adding pre-commit run --all-files as a CI step will ensure everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like pre-commit run --from-ref origin/HEAD --to-ref HEAD

Is there any way to specify the refs? Basically I want iterative improvement in CI where modified files are checked, not requiring every existing file to be in compliance.

blalor avatar Aug 13 '25 15:08 blalor

I'd love to have that, especially for monorepos! It doesn't exist, I'm not sure yet how to implement it :)

domenkozar avatar Aug 13 '25 17:08 domenkozar

Instead of using nix flake check, you could run your pre-commit commands from within nix develop. Using your example: nix develop -c pre-commit run --from-ref origin/HEAD --to-ref HEAD

sandydoo avatar Aug 13 '25 17:08 sandydoo