#!/usr/bin/env bash # # KNEL-Football Secure OS - Git Hooks Setup # Configures git to use the shared hooks from the githooks/ directory # # Run this once after cloning the repository: # ./scripts/setup-githooks.sh # # Copyright (c) 2026 Known Element Enterprises LLC # License: GNU Affero General Public License v3.0 only set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" HOOKS_DIR="$REPO_ROOT/githooks" echo "Setting up git hooks..." echo "Repository: $REPO_ROOT" echo "Hooks directory: $HOOKS_DIR" # Verify hooks directory exists if [[ ! -d "$HOOKS_DIR" ]]; then echo "ERROR: githooks/ directory not found" exit 1 fi # Make all hooks executable chmod +x "$HOOKS_DIR"/* # Configure git to use the shared hooks directory git -C "$REPO_ROOT" config core.hooksPath githooks/ # Verify configuration CONFIGURED_PATH=$(git -C "$REPO_ROOT" config --get core.hooksPath) echo "" echo "Git hooks configured successfully!" echo " core.hooksPath = $CONFIGURED_PATH" echo "" echo "Available hooks:" ls -1 "$HOOKS_DIR" echo "" echo "Hooks are now active for this repository."