Skip to content

Match pre-commit hook to CI formatting behavior

aa396a3
Select commit
Loading
Failed to load commit list.
Open

Add optional pre-commit hook for code formatting #5178

Match pre-commit hook to CI formatting behavior
aa396a3
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed May 3, 2026 in 50s

1 issue

code-review: Found 1 issue (1 high)

High

Stashed unstaged changes are lost if `dotnet format` fails due to `set -e` - `.githooks/pre-commit:2-13`

The script uses set -e at the top, then stashes unstaged changes before running dotnet format. If dotnet format exits non-zero (e.g., build/compilation error, invalid project state), set -e causes immediate script termination, skipping the git stash pop block entirely. The developer's unstaged work-in-progress changes remain in the stash with no notification, appearing lost. This is a data-loss risk and unintended side effect on every commit attempt where formatting tooling errors occur.

Also found at:

  • .githooks/pre-commit:12-13
  • .githooks/pre-commit:22-24

Duration: 46.0s · Tokens: 62.4k in / 2.7k out · Cost: $0.58 (+merge: $0.00)

Annotations

Check failure on line 13 in .githooks/pre-commit

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Stashed unstaged changes are lost if `dotnet format` fails due to `set -e`

The script uses `set -e` at the top, then stashes unstaged changes before running `dotnet format`. If `dotnet format` exits non-zero (e.g., build/compilation error, invalid project state), `set -e` causes immediate script termination, skipping the `git stash pop` block entirely. The developer's unstaged work-in-progress changes remain in the stash with no notification, appearing lost. This is a data-loss risk and unintended side effect on every commit attempt where formatting tooling errors occur.

Check failure on line 13 in .githooks/pre-commit

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[VK8-BG5] Stashed unstaged changes are lost if `dotnet format` fails due to `set -e` (additional location)

The script uses `set -e` at the top, then stashes unstaged changes before running `dotnet format`. If `dotnet format` exits non-zero (e.g., build/compilation error, invalid project state), `set -e` causes immediate script termination, skipping the `git stash pop` block entirely. The developer's unstaged work-in-progress changes remain in the stash with no notification, appearing lost. This is a data-loss risk and unintended side effect on every commit attempt where formatting tooling errors occur.

Check failure on line 24 in .githooks/pre-commit

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[VK8-BG5] Stashed unstaged changes are lost if `dotnet format` fails due to `set -e` (additional location)

The script uses `set -e` at the top, then stashes unstaged changes before running `dotnet format`. If `dotnet format` exits non-zero (e.g., build/compilation error, invalid project state), `set -e` causes immediate script termination, skipping the `git stash pop` block entirely. The developer's unstaged work-in-progress changes remain in the stash with no notification, appearing lost. This is a data-loss risk and unintended side effect on every commit attempt where formatting tooling errors occur.