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
Pre-commit does not always automatically re-apply patch when stopped with Ctrl-C #2287
Comments
can you show the whole output? |
Sure, there's not a whole lot to show since I hit ctrl-c early on in the process:
I was able to get back to a normal state just by |
that's some crazy quick reaction time -- that's the first ~100ms of execution. I'm not sure there's too much that can be done since it's ms before it would have set up the finalizer |
Hmm, without knowing too much about the code or how it works but reading https://github.com/pre-commit/pre-commit/blob/master/pre_commit/staged_files_only.py#L69 Would it make any sense to do something like this? # ...
no_checkout_env = dict(os.environ, _PRE_COMMIT_SKIP_POST_CHECKOUT='1')
try:
cmd_output_b(*_CHECKOUT_CMD, env=no_checkout_env)
yield
finally:
# Try to apply the patch we saved
# ... I am guessing the subprocess to perform the |
the problem with that is it would apply in cases where it was cancelled to early causing a different failure |
there's a rare race outlined in #2287
I was able to reproduce with sleep insertion but not actual execution -- but in theory it could pause there so I moved the call inside -- hopefully that should fix this! |
Thanks for the fix! I will give the new version a try and report back if I still run into trouble. |
there's a rare race outlined in pre-commit#2287
As mentioned in this issue:
Originally posted by @asottile in #2251 (comment)
I reproduced it once, although unfortunately I can't share the config since it is from a private repository in my organization, I do have a log which might provide a clue where this is happening.
In this case, the affected repo uses around 35 hooks, some custom and some from various upstreams. I was doing a
git commit --amend
but forgot to stage some changes, so I canceled to try agit commit --amend -a
instead, when I hit the issue.version information
error information
The text was updated successfully, but these errors were encountered: