-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-install.sh
More file actions
executable file
·69 lines (56 loc) · 2.06 KB
/
Copy path.pre-commit-install.sh
File metadata and controls
executable file
·69 lines (56 loc) · 2.06 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
69
#!/bin/bash
# Pre-commit setup script for Rock Node
# This script installs and configures pre-commit hooks
set -euo pipefail
echo "🔧 Setting up pre-commit hooks for Rock Node..."
# Check if Python is available
if ! command -v python3 &> /dev/null && ! command -v python &> /dev/null; then
echo "❌ Python is required to install pre-commit"
echo "Please install Python 3.6+ and try again"
exit 1
fi
# Determine Python command
PYTHON_CMD=""
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
fi
echo "📦 Installing pre-commit..."
# Install pre-commit using pip
$PYTHON_CMD -m pip install --user pre-commit
# Verify installation
if ! command -v pre-commit &> /dev/null; then
echo "❌ pre-commit installation failed or not in PATH"
echo "Please ensure ~/.local/bin is in your PATH"
echo "Add this to your shell profile: export PATH=\"\$HOME/.local/bin:\$PATH\""
exit 1
fi
echo "✅ pre-commit installed successfully"
# Install the git hooks
echo "🔗 Installing git hooks..."
pre-commit install
# Install hooks for commit messages (optional)
pre-commit install --hook-type commit-msg
echo "🧪 Running pre-commit on all files (this may take a while)..."
# Run on all files to ensure everything is set up correctly
pre-commit run --all-files || {
echo "⚠️ Some checks failed. This is normal for the first run."
echo "Pre-commit has been installed and will run on future commits."
}
echo ""
echo "✅ Pre-commit setup complete!"
echo ""
echo "📋 What happens now:"
echo " • Pre-commit hooks will run automatically on each commit"
echo " • Code will be formatted with rustfmt"
echo " • Code will be linted with clippy"
echo " • Unit tests will run (excluding e2e tests)"
echo " • Basic file checks will be performed"
echo ""
echo "🛠️ Manual commands:"
echo " • Run on all files: pre-commit run --all-files"
echo " • Update hooks: pre-commit autoupdate"
echo " • Skip hooks (if needed): git commit --no-verify"
echo ""
echo "🚀 Happy coding!"