fix(framework): guard dispatch-level host resolution against a missing git origin (pr-review.sh)
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
Independent review of PR #896 found the -r/--repo + -H/--host overrides had a real bug that this addresses: 1. The approve/request-changes/comment dispatch bodies each independently called a BARE `host=$(get_remote_host)` (used only for a best-effort tea-login guess) that ignored -H/--host entirely and, under `set -e`, died SILENTLY (exit 1, zero stdout/stderr) whenever there was no git origin at all — exactly the "reviewer worktree with no usable origin" case -r/-H exist to support. This was WORSE than the pre-5/5c baseline, which at least failed loud at detect_platform. Fixed by preferring -H/--host and otherwise tolerating a missing/failing git-remote lookup for that best-effort guess: `host="${HOST_OVERRIDE:-$(get_remote_host 2>/dev/null || true)}"`. 2. The regression test's "no git origin" fixture was a subdirectory NESTED inside this checkout, so `git remote get-url origin` resolved UPWARD to the checkout's own real origin — the "tolerates a missing origin" assertions never actually exercised a no-origin case. Fixed by creating that fixture via `mktemp -d` under the system /tmp (truly outside any .git ancestry) and additionally bounding it with GIT_CEILING_DIRECTORIES, plus a fixture self-check that fails the harness if `git remote get-url origin` ever resolves from inside it. Extended coverage to approve/request-changes (not just comment), each asserting the run is not silently dead (exit != 0 with zero combined output) in the true no-origin dir. Reproduce-first evidence: with the CORRECTED fixture, re-running the regression test against the previous (round-1) pr-review.sh reproduces the exact reported failure — "died SILENTLY (exit 1, zero output)" — for the `comment` action; the fix in this commit resolves it for comment, approve, and request-changes alike. Re-verified: pnpm run test:framework-shell (both pr-review tests + full chain) green; shellcheck 0 new findings; grep -niE 'jason|woltje|jarvis' 0 hits; verify-sanitized.sh passed. Part of #891
This commit is contained in:
@@ -629,7 +629,14 @@ if [[ "$PLATFORM" == "github" ]]; then
|
||||
elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||
case $ACTION in
|
||||
approve)
|
||||
host=$(get_remote_host)
|
||||
# Best-effort host for the tea-login GUESS only (gitea_resolve_api_for_login
|
||||
# below re-derives the real host from HOST_OVERRIDE/remote independently and
|
||||
# is authoritative). Prefer an explicit -H/--host; otherwise best-effort
|
||||
# git-remote inference, tolerating its ABSENCE (a bare `get_remote_host` here
|
||||
# under `set -e`, with no origin and no -H, previously killed the script
|
||||
# SILENTLY — exit 1, zero output — even though -r/-H are exactly the flags
|
||||
# that support running with no usable origin at all).
|
||||
host="${HOST_OVERRIDE:-$(get_remote_host 2>/dev/null || true)}"
|
||||
# A --login override always wins. Otherwise name this host's login
|
||||
# only as a best effort: the login name merely selects a per-login
|
||||
# token, and gitea_resolve_api_for_login falls back to the host
|
||||
@@ -659,7 +666,14 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||
echo "Error: Comment required for request-changes"
|
||||
exit 1
|
||||
fi
|
||||
host=$(get_remote_host)
|
||||
# Best-effort host for the tea-login GUESS only (gitea_resolve_api_for_login
|
||||
# below re-derives the real host from HOST_OVERRIDE/remote independently and
|
||||
# is authoritative). Prefer an explicit -H/--host; otherwise best-effort
|
||||
# git-remote inference, tolerating its ABSENCE (a bare `get_remote_host` here
|
||||
# under `set -e`, with no origin and no -H, previously killed the script
|
||||
# SILENTLY — exit 1, zero output — even though -r/-H are exactly the flags
|
||||
# that support running with no usable origin at all).
|
||||
host="${HOST_OVERRIDE:-$(get_remote_host 2>/dev/null || true)}"
|
||||
# A --login override always wins. Otherwise name this host's login
|
||||
# only as a best effort: the login name merely selects a per-login
|
||||
# token, and gitea_resolve_api_for_login falls back to the host
|
||||
@@ -683,7 +697,14 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||
echo "Error: Comment required"
|
||||
exit 1
|
||||
fi
|
||||
host=$(get_remote_host)
|
||||
# Best-effort host for the tea-login GUESS only (gitea_resolve_api_for_login
|
||||
# below re-derives the real host from HOST_OVERRIDE/remote independently and
|
||||
# is authoritative). Prefer an explicit -H/--host; otherwise best-effort
|
||||
# git-remote inference, tolerating its ABSENCE (a bare `get_remote_host` here
|
||||
# under `set -e`, with no origin and no -H, previously killed the script
|
||||
# SILENTLY — exit 1, zero output — even though -r/-H are exactly the flags
|
||||
# that support running with no usable origin at all).
|
||||
host="${HOST_OVERRIDE:-$(get_remote_host 2>/dev/null || true)}"
|
||||
# A --login override always wins. Otherwise name this host's login
|
||||
# only as a best effort: the login name merely selects a per-login
|
||||
# token, and gitea_resolve_api_for_login falls back to the host
|
||||
|
||||
Reference in New Issue
Block a user