-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·44 lines (37 loc) · 1.38 KB
/
Copy pathpre-commit
File metadata and controls
executable file
·44 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Git pre-commit hook to check README sync
# Install this hook by running: ./scripts/install-hooks.sh
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "🔍 Pre-commit: Checking README sync..."
# Check if README.md or src/lib.rs are being committed
if git diff --cached --name-only | grep -qE "^(README.md|src/lib.rs)$"; then
echo "📝 Documentation files modified, running sync check..."
# Run the full README sync check script
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