#!/usr/bin/env bash
set -euo pipefail

# Installation script for homelab pre-commit hooks
# To be run manually once or integrated into a bootstrap process.

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${REPO_ROOT}"

if ! command -v pre-commit >/dev/null 2>&1; then
    printf 'Installing pre-commit...\n'
    pip install --user pre-commit
    export PATH="$HOME/.local/bin:$PATH"
fi

printf 'Installing git hooks...\n'
pre-commit install

printf 'Running initial check on staged files...\n'
pre-commit run --all-files

printf 'Pre-commit hooks installed and verified.\n'
