-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-git-hooks.sh
More file actions
31 lines (26 loc) · 809 Bytes
/
setup-git-hooks.sh
File metadata and controls
31 lines (26 loc) · 809 Bytes
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
HOOKS_DIR=".git-hooks"
GIT_HOOKS_DIR=".git/hooks"
echo "🔧 Setting up Git hooks..."
if [ ! -d ".git" ]; then
echo "❌ Error: Not a git repository"
exit 1
fi
if [ -f "$HOOKS_DIR/pre-commit" ]; then
cp "$HOOKS_DIR/pre-commit" "$GIT_HOOKS_DIR/pre-commit"
chmod +x "$GIT_HOOKS_DIR/pre-commit"
echo "✅ pre-commit hook installed"
else
echo "⚠️ Warning: pre-commit hook not found in $HOOKS_DIR"
fi
echo ""
echo "Testing pre-commit hook..."
if [ -x "$GIT_HOOKS_DIR/pre-commit" ]; then
echo "✅ Git hooks successfully installed and executable"
echo ""
echo "Next steps:"
echo " 1. Try committing a file with 'AIzaSy' in it (will be blocked)"
echo " 2. Check SECURITY.md for best practices"
else
echo "❌ Error: Hook installation failed"
exit 1
fi