Files
sproutclaw/.husky/pre-commit
shumengya 9ed9ed91dd chore: remove .pi config from git tracking
.pi 是本地持久化配置目录,不应上传到仓库。
从追踪中移除所有 .pi 文件,并在 .gitignore 顶部添加整体排除规则。
同时修复 pre-commit hook 在 gitignore 文件重 add 时不报错。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-21 19:45:14 +08:00

46 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Get list of staged files before running check
STAGED_FILES=$(git diff --cached --name-only)
node scripts/check-lockfile-commit.mjs
if [ $? -ne 0 ]; then
exit 1
fi
# Run the check script (formatting, linting, and type checking)
echo "Running formatting, linting, and type checking..."
npm run check
if [ $? -ne 0 ]; then
echo "❌ Checks failed. Please fix the errors before committing."
exit 1
fi
RUN_BROWSER_SMOKE=0
for file in $STAGED_FILES; do
case "$file" in
packages/ai/*|packages/web-ui/*|package.json|package-lock.json)
RUN_BROWSER_SMOKE=1
break
;;
esac
done
if [ $RUN_BROWSER_SMOKE -eq 1 ]; then
echo "Running browser smoke check..."
npm run check:browser-smoke
if [ $? -ne 0 ]; then
echo "❌ Browser smoke check failed."
exit 1
fi
fi
# Restage files that were previously staged and may have been modified by formatting
for file in $STAGED_FILES; do
if [ -f "$file" ]; then
git add "$file" 2>/dev/null || true
fi
done
echo "✅ All pre-commit checks passed!"