-
Notifications
You must be signed in to change notification settings - Fork 56
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
Error with pre-commit: Error when running on git HEAD commit #180
Comments
Thanks @jabesq for the report! Have you had a chance to look at Darker's code to see what could be the reason for this? |
This is actually where I don't understand how pre-commit is supposed to work. If I'm comparing two old revisions in the repository, should the linter still overwrite the corrected file in the working tree even though it might not be identical to the Consider the following chain of events:
So if Darker now detects that some lines modified between There was a previous discussion about this in Darker #2. Could you review that and see if it clarifies the current problem? |
A-ha, pre-commit documentation on pre-commit during commits says:
So if I'm not mistaken, this means that a hook (like Darker) can safely modify the files on disk in whatever way, since pre-commit will stash and unstash the current working tree anyway. In other words, if pre-commit invokes Darker with Could someone please verify that this is a correct interpretation? |
Ok so I tried this out.
So the behavior of
I wonder if I'm getting this right. I'm also curious to know when |
I'm thinking Darker could allow a non-
I'm hesitant to allow this behavior for other values of |
Versions:
pre-commit configuration:
Step to reproduce:
Run pre-commit on git HEAD that contains black or isort errors with the following command:
$> pre-commit run -s HEAD^ -o HEAD
Error:
pre-commit fails at the darker step with the following error message:
The text was updated successfully, but these errors were encountered: