Skip to content

Run hooks only for staged / commited changes #136

Description

@majkel89

Details

Be able to run hooks only for staged (commit-msg, pre-commit) or committed (pre-push) changes.

The problem:

  1. When developer runs dotnet format via pre-commit hook all upstaged changes are formatted and committed. This will include lines that are not intended to be part of the commit. Developer could have used git add -i for staging the changes.
  2. When developers run dotnet build / dotnet tests via pre-push hook the project is build with uncommitted changes. This could lead to pushing changes that are passing locally but failing in CI/CD pipeline and vice-versa.

Solution:
Stash upstaged / uncommitted changes when hook is invoked

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions