#!/usr/bin/env bash
# Secret scan of the staged changes before each commit (gitleaks, rules in
# .gitleaks.toml). `git config core.hooksPath .githooks` turns it on per
# clone. Without gitleaks it warns and lets the commit through: CI scans every
# push again (.gitea/scripts/gitleaks.sh).
PATH="$PATH:$HOME/bin"
if ! command -v gitleaks >/dev/null 2>&1; then
  echo "pre-commit: gitleaks not found; install it (https://github.com/gitleaks/gitleaks/releases) to scan commits before they leave this machine" >&2
  exit 0
fi
exec gitleaks git --pre-commit --staged --redact --no-banner --verbose
