#!/usr/bin/env bash
# docmv pre-push hook: refuse to push if the test suite is red.
#
# Install:  git config core.hooksPath hooks
#
# Set DOCMV_SKIP_HOOK=1 to bypass in an emergency (discouraged).
set -euo pipefail

if [[ "${DOCMV_SKIP_HOOK:-0}" == "1" ]]; then
    echo "docmv pre-push: skipped (DOCMV_SKIP_HOOK=1)"
    exit 0
fi

# hooks/ lives at the repo root, so the package dir is one level up.
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

echo "docmv pre-push: running test suite in $repo_root"
( cd "$repo_root" && uv run --extra dev pytest -q )
echo "docmv pre-push: OK"
