mirror of
https://github.com/luongnv89/claude-howto.git
synced 2026-08-08 00:08:36 +02:00
Internal accuracy pass against v2.1.220 — no missing upstream features, but broken example code, disagreeing counts, and metadata drift.
Functional fixes: pre-commit.sh now exits 2 so it actually blocks; dependency-check.sh reads file_path from stdin JSON instead of $1; database-mcp.json uses ${DATABASE_URL}; broken fences repaired; three command templates had invalid skill names.
Factual corrections: /fork and /subtask unswapped and /subtask added; /fewer-permission-prompts; permissions.defaultMode; dontAsk/auto unreversed; 31 hook events verified name-by-name; subagent depth 3; skill precedence enterprise > project > personal; /output-style removed not deprecated; permissionDecision gained defer.
Follow-up review fixed defects the pass left behind: zh/vi headers claiming 31 events above 25-name lists, a surviving hardcoded DB credential in the MCP README examples, an unbalanced fence swallowing a metadata footer, and non-canonical tool names. All four translated CATALOG summary tables were recounted so their arithmetic holds.
Full detail in CHANGELOG.md under v2.1.220-r2.
55 lines
1.4 KiB
Bash
55 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# Run tests before commit
|
|
# Hook: PreToolUse (matcher: Bash) - checks if the command is a git commit
|
|
# Note: There is no "PreCommit" hook event. Use PreToolUse with a Bash matcher
|
|
# and inspect the command to detect git commit operations.
|
|
#
|
|
# Exit codes: 2 blocks the tool call and surfaces stderr as the block reason.
|
|
# Any other non-zero value is a NON-blocking error — the commit would proceed.
|
|
# Source: https://code.claude.com/docs/en/hooks
|
|
|
|
echo "🧪 Running tests before commit..."
|
|
|
|
# Check if package.json exists (Node.js project)
|
|
if [ -f "package.json" ]; then
|
|
if grep -q "\"test\":" package.json; then
|
|
npm test
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Tests failed! Commit blocked." >&2
|
|
exit 2
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Check if pytest is available (Python project)
|
|
if [ -f "pytest.ini" ] || [ -f "setup.py" ]; then
|
|
if command -v pytest &> /dev/null; then
|
|
pytest
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Tests failed! Commit blocked." >&2
|
|
exit 2
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Check if go.mod exists (Go project)
|
|
if [ -f "go.mod" ]; then
|
|
go test ./...
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Tests failed! Commit blocked." >&2
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
# Check if Cargo.toml exists (Rust project)
|
|
if [ -f "Cargo.toml" ]; then
|
|
cargo test
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Tests failed! Commit blocked." >&2
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
echo "✅ All tests passed! Proceeding with commit."
|
|
exit 0
|