Open dsedivec opened 5 years ago
Hi @dsedivec
There are two use cases:
pre-commit run --all-files
Since the second use case covers the first (and then some, admittedly), I lazily implemented the second use case. I'm certainly open to support both individually.
Do you know if there's a way to detect if pre-commit
is invoked with --all-files
?
Hi @jumanjiman!
There are two use cases:
- Check only the files that are part of the current commit as a pre-commit hook
- Check the entire tree in case of
pre-commit run --all-files
Since the second use case covers the first (and then some, admittedly), I lazily implemented the second use case. I'm certainly open to support both individually.
Do you know if there's a way to detect if
pre-commit
is invoked with--all-files
?
OK, I didn't think of --all-files
, good point. Can you set pass_filenames: True
in the hook's definition, and then just pass all of the file names on the command line into git diff-index
?
OK, I didn't think of
--all-files
, good point. Can you setpass_filenames: True
in the hook's definition, and then just pass all of the file names on the command line intogit diff-index
?
That's a nifty thought to try.
i'll have to play with it and see if I can somehow also support the exclude*
options.
I also hit this issue ;-(
Having a repo with so many files and adopting changes in the pre-commit
hooks I run it w/ -a
and see that this hook forks a lot of git diff-index --check some-hash
processes w/ the same hash (meaning that it ignores all that 100500 files given as parameters and performs the same command 100500 times!)
PS It's running for 30 minutes already and still not finished ;-()
Thanks for writing the git-check plug-in! I was surprised, though, to find that it checks my whole tree, not just staged changes against the prior commit (if any).
Should it be calling
git diff-index
with--cached
, and preferringHEAD
, when it exists, to${EMPTY_COMMIT}
?