Skip to content

Add --staged flag to only check changes in staged codeΒ #4328

Open
@abemedia

Description

@abemedia

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.

git stash --keep-index --include-untracked --quiet
exitCode=0
golangci-lint run || exitCode=$?
git stash pop --quiet
exit $exitCode

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementno decisionNo decision to fix or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions