From bd50ef7e387a423e19aef8e096b3d60bf0a78e80 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Sat, 9 May 2026 20:30:36 +0300 Subject: [PATCH] fix: only re-stage previously staged files in pre-commit hook Capture staged file list before prettier runs, then re-add only those files. Prevents pulling in unrelated unstaged changes. Co-Authored-By: Claude Opus 4.6 (1M context) --- .husky/pre-commit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 3bcac61b2..379c43ce0 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,5 @@ +staged=$(git diff --cached --name-only --diff-filter=ACM -- 'src/**/*.ts') pnpm run format:fix -git diff --name-only -- 'src/**/*.ts' | xargs git add 2>/dev/null || true +if [ -n "$staged" ]; then + echo "$staged" | xargs git add +fi