Home > OS >  Is it possible to pre-commit run on --from-ref/--to-ref and staged files together
Is it possible to pre-commit run on --from-ref/--to-ref and staged files together

Time:11-12

When I invoke:

  • pre-commit run --from-ref origin/develop --to-ref HEAD: it runs on already committed files
  • pre-commit run: it runs on staged files

Is there a way to have pre-commit run on both in one command?

CodePudding user response:

I'm not sure why you would ever want to do that -- seems like an XY problem

that said, it's always possible to utilize pre-commit run --files to run on whatever set of files you want to

combining the two:

(git diff --staged --name-only -z && git diff --name-only -z origin/develop...HEAD) | xargs -0 pre-commit run --files

disclaimer: I wrote pre-commit

  • Related