#!/usr/bin/env bash
# Test harness only (PR #23579 capture): while $EV_HOLD_FLAG exists, git commands run with cwd == $EV_HOLD_ROOT
# block (max 150 s). This stalls ThreadLaunch's synchronous base-ref preflight for the first webhook run,
# so that run holds the task's permit and later deliveries queue behind it. Otherwise execs the real git.
if [ -n "${EV_HOLD_FLAG:-}" ] && [ -f "$EV_HOLD_FLAG" ] && [ "$(pwd -P)" = "$EV_HOLD_ROOT" ]; then
  echo "$(date -u +%FT%T.%3NZ) hold git $*" >> "$EV_HOLD_FLAG.log"
  for _ in $(seq 150); do [ -f "$EV_HOLD_FLAG" ] || break; sleep 1; done
fi
exec /usr/bin/git "$@"
