-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-precommit.sh
More file actions
executable file
·58 lines (50 loc) · 1.59 KB
/
setup-precommit.sh
File metadata and controls
executable file
·58 lines (50 loc) · 1.59 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
#!/bin/bash
# Setup pre-commit for ShellCast project
# This script installs pre-commit in both analysis and web environments
set -e
echo "🔧 Setting up pre-commit for ShellCast project..."
# Check if pre-commit is installed globally
if ! command -v pre-commit &> /dev/null; then
echo "📦 Installing pre-commit globally..."
pip install pre-commit
else
echo "✅ pre-commit is already installed globally"
fi
# Check if shellcheck is available (optional)
if command -v shellcheck &> /dev/null; then
echo "✅ shellcheck is available for shell script linting"
else
echo "⚠️ shellcheck not found - shell script linting will be skipped"
echo " Install with: brew install shellcheck (macOS) or apt-get install shellcheck (Ubuntu)"
fi
# Install pre-commit hooks
echo "🔗 Installing pre-commit hooks..."
pre-commit install
# Install pre-commit in analysis environment
echo "🐍 Installing pre-commit in analysis environment..."
cd analysis/shellcast-analysis
source analysisenv/bin/activate
pip install pre-commit
deactivate
cd ../..
# Install pre-commit in web environment
echo "🌐 Installing pre-commit in web environment..."
cd web
source webvenv/bin/activate
pip install pre-commit
deactivate
cd ..
echo "✅ Pre-commit setup complete!"
echo ""
echo "📋 Usage:"
echo " # Run pre-commit on all files"
echo " pre-commit run --all-files"
echo ""
echo " # Run pre-commit on staged files only"
echo " git commit"
echo ""
echo " # Update pre-commit hooks"
echo " pre-commit autoupdate"
echo ""
echo " # Skip pre-commit for a commit (not recommended)"
echo " git commit --no-verify"