forked from ChuyueSun/VeriStruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_precommit.sh
More file actions
executable file
·68 lines (59 loc) · 1.91 KB
/
Copy pathsetup_precommit.sh
File metadata and controls
executable file
·68 lines (59 loc) · 1.91 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# Setup script for pre-commit hooks
set -e
echo "=========================================="
echo " Setting up Pre-commit Hooks"
echo "=========================================="
echo ""
# Check if pip is available
if ! command -v pip &> /dev/null; then
echo "❌ Error: pip is not installed. Please install Python and pip first."
exit 1
fi
# Install pre-commit
echo "📦 Installing pre-commit..."
pip install pre-commit
# Check if Rust is available
if ! command -v rustc &> /dev/null; then
echo "⚠️ Warning: Rust is not installed."
echo " Some pre-commit hooks for Rust formatting won't work."
echo " Install Rust from: https://rustup.rs/"
echo ""
else
# Ensure rustfmt and clippy are installed
echo "🦀 Setting up Rust tools..."
rustup component add rustfmt clippy 2>/dev/null || true
fi
# Install git hooks
echo "🔧 Installing git hooks..."
pre-commit install
# Run pre-commit on all files to see current status
echo ""
echo "🔍 Running pre-commit checks on all files..."
echo " (This may take a while on first run)"
echo ""
if pre-commit run --all-files; then
echo ""
echo "✅ All pre-commit checks passed!"
else
echo ""
echo "⚠️ Some pre-commit checks failed or made changes."
echo " Review the changes and commit them if appropriate."
echo ""
echo " To commit the auto-fixes:"
echo " git add -u"
echo " git commit -m 'Apply pre-commit auto-fixes'"
fi
echo ""
echo "=========================================="
echo " Pre-commit Setup Complete!"
echo "=========================================="
echo ""
echo "Your pre-commit hooks are now active."
echo "They will run automatically on 'git commit'."
echo ""
echo "Useful commands:"
echo " - Run manually: pre-commit run --all-files"
echo " - Update hooks: pre-commit autoupdate"
echo " - Skip hooks: git commit --no-verify (not recommended)"
echo ""