evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.66k stars 211 forks source link

"no matching staged files" error when I ran "pre-commit" manually #712

Closed yuseferi closed 3 months ago

yuseferi commented 3 months ago

:wrench: Summary

When I want to run my "pre-commit" manually with "lefthook run pre-commit" it returns "no matching staged files" which shouldn't be like this, because I run it manually it it should not be sensetive on stage/unstage status of file.

Lefthook version

1.6.10

Steps to reproduce

create a pre-commit, and try to run it manually

Expected results

pre commit should be run

Actual results

"no matching staged files"

Possible Solution

when run comes from the manual source do ignore stage/unistage file situation

mrexox commented 3 months ago

Hey! You can use --force option that will omit the filters if you have them (like glob, exclude). Or you can run the pre-commit hook against all files, so any of these may work:

# Agains all staged files without filtering
lefthook run pre-commit --force

# Agains all files
lefthook run pre-commit --all-files --force

Or if these options don't work for you, could you share your lefthook config, so I could think out a possible solution?

yuseferi commented 3 months ago

Thank you for the quick reply. I will close this 🙏