set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "đ Pre-commit: Checking README sync..."
if git diff --cached --name-only | grep -qE "^(README.md|src/lib.rs)$"; then
echo "đ Documentation files modified, running sync check..."
if ! ./scripts/check-readme-sync.sh > /tmp/readme-sync.log 2>&1; then
echo -e "${RED}â README sync check failed!${NC}"
echo ""
echo "Output from check-readme-sync.sh:"
cat /tmp/readme-sync.log
echo ""
echo -e "${RED}Please fix the sync issues before committing.${NC}"
echo " 1. Edit doc comments in src/lib.rs"
echo " 2. Mirror changes to README.md"
echo " 3. Run: cargo test --doc"
echo " 4. Run: ./scripts/check-readme-sync.sh"
echo ""
echo "To bypass this check (not recommended):"
echo " git commit --no-verify"
rm -f /tmp/readme-sync.log
exit 1
fi
echo -e "${GREEN}â README sync check passed${NC}"
rm -f /tmp/readme-sync.log
else
echo "âšī¸ No documentation files modified, skipping sync check"
fi
echo -e "${GREEN}â Pre-commit checks passed${NC}"
exit 0