Skip to content

Commit 008cc4f

Browse files
committed
fix: preserve staged changes after pre-commit hook
- Store list of staged files before running linting - Re-stage files modified by linting tools - Prevent unstaged changes from being excluded from commit 🤖 Generated with Claude via commitment
1 parent 735b0ec commit 008cc4f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.husky/pre-commit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
#!/bin/sh
22
# Run linting and build to ensure code quality and dist is up to date
3+
4+
# Get list of staged files before linting
5+
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
6+
7+
# Run linting (which may modify files)
38
bun run lint
49
bun run build
10+
11+
# Re-stage any files that were modified by linting
12+
if [ -n "$STAGED_FILES" ]; then
13+
echo "$STAGED_FILES" | while IFS= read -r file; do
14+
if [ -f "$file" ]; then
15+
git add "$file"
16+
fi
17+
done
18+
fi

0 commit comments

Comments
 (0)