#!/usr/bin/env bash
# Mugi post-commit hook: detect and warn about pre-commit bypasses.
# When `git commit --no-verify` is used, the pre-commit hook never runs and never
# clears its marker. We can't directly detect "was --no-verify used", but we can
# write a marker FROM pre-commit on success and read it here on failure-of-marker.
#
# The simpler convention used here: print a one-line nag if the most recent
# commit's diff includes Python files but no smoke run was logged in the
# MUGI_SMOKE_BYPASSED file. Best-effort; never blocks.
set -e

repo_root=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
cd "$repo_root"

if [ -f .git/MUGI_SMOKE_BYPASSED ]; then
  echo ""
  echo "[mugi-post-commit] Heads up: pre-commit smoke was BYPASSED for this commit."
  echo "                   Run 'make smoke' before you push."
  rm -f .git/MUGI_SMOKE_BYPASSED
fi
exit 0
