#!/bin/sh
# Test fixture: a fake `gh` for apps/review/tests/action.
#
# Checked in and executable (not written at test time) so spawning it never
# races a fresh write-then-exec (see tests/github/fixtures/fake-gh).
#
# Prints $SMITHERS_FAKE_GH_STDOUT and exits with $SMITHERS_FAKE_GH_EXIT
# (default 0, printing stderr on failure), so tests can script gh responses.
# Optionally append each call's arguments and stdin for status-comment assertions.
if [ -n "$SMITHERS_FAKE_GH_LOG" ]; then
  {
    printf '%s\n' '--- fake gh call ---' "$@"
    cat
    printf '\n'
  } >> "$SMITHERS_FAKE_GH_LOG"
fi
if [ "${SMITHERS_FAKE_GH_EXIT:-0}" -ne 0 ]; then
  printf 'fake gh failure' >&2
  exit "$SMITHERS_FAKE_GH_EXIT"
fi
printf '%s' "$SMITHERS_FAKE_GH_STDOUT"
