-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add --staged flag to only check changes in staged code #4328
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
hey @abemedia , are there any current proposals on how to tackle that? I'm looking for this exact solution, would be glad to work on PR later if you haven't started yet 👍 |
Well there's already logic to just use a patch file. One could implement this by generating a patch file from the currently staged changes. |
Hello, FYI, the current behavior is based on
Maybe |
ah, I wasn't aware of the |
My comment was not really a suggestion but more a technical thinking. I'm not sure of the value of an option, only for a niche, that can be done easily with the command line. git diff --cached > /tmp/stage.patch; golangci-lint run --new-from-patch=/tmp/stage.patch; rm /tmp/stage.patch git diff --cached > /tmp/stage.patch
golangci-lint run --new-from-patch=/tmp/stage.patch
rm /tmp/stage.patch Maybe this can be a new hook inside our pre-commit hook file. 🤔 Also, note that running golangci-lint only on a few files can lead to unexpected behavior with linters (the majority) that require scanning all files. |
Yeah, to be honest I've had the same thought. After reading your comments, I re-wrote my pre commit hook to do pretty much the same as you've suggested above. I'm just sad since this was an easy first contribution 😅
I wasn't aware of this though - thanks for raising it 👍 |
I think a Ideally I should be able to use this in conjunction with |
Your feature request related to a problem? Please describe.
I use golangci-lint in pre-commit hooks and without adding a custom script to first stash unstaged changes this results in the pre-commit hook failing if there are issues in unstaged code.
Describe the solution you'd like.
A new flag
--staged
which ignores all issues that are not in staged changes.Describe alternatives you've considered.
A custom pre-commit script which first stashes the changes e.g.
The problem with this solution is that it can result in the loss of what is currently staged and what isn't.
Additional context.
No response
The text was updated successfully, but these errors were encountered: