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) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-05-09 20:30:36 +03:00
parent 25a5b81c59
commit bd50ef7e38
+4 -1
View File
@@ -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