- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 933
Inspecting the index during a pre-commit is empty #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the clear issue description, very informative! It's not the first time I hear that git hooks aren't working as they should depending on how executes them. Most often they fail in cron jobs though. Since the If it is, you might try to re-throw this OSError as it's the only reason it would yield an empty index. Unfortunately it doesn't check the actual cause of the error, it should only yield an empty index if the file isn't present yet, which should barely ever be happening. |
So adding the code: lfd = LockedFD(index._file_path)
lfd.open(write=False, stream=False) led to a stack trace (below), which mentions that there is already an Otherwise I'll have to reconsider my approach to checking the index Stack trace:
|
I have created a new release which simply won't take a read lock anymore - it's not required at all, to solve this particular problem. |
Thank you, that fixed my issue :) |
I've written a small script to work with pre-commit, which when run locally seems to work but when I run it through pre-commit the git index is empty and I get errors.
The issue I'm seeing is when I run the script via PyCharm the checks pass, but when it's run automatically by pre-commit the
meta_file_in_index
fails because theindex
appears to be empty.Any advice on what I'm doing wrong or suggestions for digging deeper into what's going on would be greatly appreciated.
What I've done so far:
The issue raised with pre-commit: pre-commit/pre-commit#2184
Source Code:
The text was updated successfully, but these errors were encountered: