forked from huiskylabs/solana-validator-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-hooks.sh
More file actions
executable file
·44 lines (38 loc) · 1.3 KB
/
setup-hooks.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.3 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
# Setup script to install Git hooks
set -e
echo "🔧 Setting up Git hooks..."
# Create .git/hooks directory if it doesn't exist
mkdir -p .git/hooks
# Install pre-commit hook
if [ -f ".githooks/pre-commit" ]; then
cp .githooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo "✅ Pre-commit hook installed"
else
echo "❌ Pre-commit hook not found in .githooks/pre-commit"
exit 1
fi
# Install cargo-audit if not present
if ! command -v cargo-audit &> /dev/null; then
echo "📦 Installing cargo-audit for security checks..."
cargo install cargo-audit
echo "✅ cargo-audit installed"
else
echo "✅ cargo-audit already installed"
fi
echo "🎉 Git hooks setup complete!"
echo ""
echo "ℹ️ The pre-commit hook will now run the following checks before each commit:"
echo " (These match exactly with GitHub Actions CI)"
echo " - Code formatting (cargo fmt -- --check)"
echo " - Clippy linting (cargo clippy -- -D warnings)"
echo " - Tests (cargo test --verbose)"
echo " - Build (cargo build --verbose --release)"
echo " - Security audit (cargo audit)"
echo ""
echo "💡 To bypass the pre-commit hook in emergencies, use:"
echo " git commit --no-verify"
echo ""
echo "🔧 To manually run the pre-commit checks:"
echo " .githooks/pre-commit"