#!/bin/bash # # 🔒 ROA2WEB Git Hooks Installer # Installs security git hooks to prevent secrets commits # set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${GREEN}🔒 Installing ROA2WEB Security Git Hooks${NC}" echo "==========================================" # Check if we're in a git repository if [[ ! -d ".git" ]]; then echo -e "${RED}❌ Error: Not in a git repository${NC}" exit 1 fi # Create hooks directory if it doesn't exist mkdir -p .git/hooks # Install pre-commit hook if [[ -f "security/git_hooks/pre-commit" ]]; then cp security/git_hooks/pre-commit .git/hooks/pre-commit chmod +x .git/hooks/pre-commit echo -e "${GREEN}✅ Installed pre-commit hook${NC}" else echo -e "${RED}❌ Error: pre-commit hook file not found${NC}" exit 1 fi # Install commit-msg hook if [[ -f "security/git_hooks/commit-msg" ]]; then cp security/git_hooks/commit-msg .git/hooks/commit-msg chmod +x .git/hooks/commit-msg echo -e "${GREEN}✅ Installed commit-msg hook${NC}" else echo -e "${RED}❌ Error: commit-msg hook file not found${NC}" exit 1 fi echo "" echo -e "${GREEN}🎉 Git hooks installed successfully!${NC}" echo "" echo "📋 Installed hooks:" echo " • pre-commit - Scans for secrets before commit" echo " • commit-msg - Validates commit messages" echo "" echo "🔧 To bypass hooks (NOT RECOMMENDED):" echo " git commit --no-verify" echo "" echo "🗑️ To uninstall hooks:" echo " rm .git/hooks/pre-commit .git/hooks/commit-msg"