ci/woodpecker/pr/ci Pipeline failed
be-coder-08, reviewing #1086, found the diagnostic is not diagnostic-only. At all three call sites it was written as the last command of an && list: declare -F explain_tea_user_does_not_exist >/dev/null && explain_tea_user_does_not_exist and it sits immediately BEFORE the Gitea API fallback. Under `set -e` a failing diagnostic (stderr closed or full) therefore exits the script and the fallback never runs -- a diagnostic that suppresses the recovery path it exists to explain. The asymmetry is what makes it dangerous: the fault only appears when the helper is PRESENT, so the helper-absent path -- the pre-#1086 behaviour -- keeps working and reads as a passing control. Measured on /dev/full: helper present rc=1 fallback NOT reached helper absent rc=0 fallback reached Wrapping in `{ ...; } || true` makes the diagnostic status-neutral, which is what the PR claimed to be in the first place. test-explain-diagnostic-status-neutral.sh probes all four combinations of {helper present, absent} x {stderr ok, failing} for each of the three call sites, and lifts the construct FROM THE SHIPPED FILE rather than restating it -- a probe that retypes the fixed form passes on a build whose real call sites still carry the bare && form. Verified RED on the pre-fix tree (16 failures, behavioural half included) and GREEN here. Enumerated on test:framework-shell. Reported-by: be-coder-08
81 lines
2.2 KiB
Bash
Executable File
81 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# issue-view.sh - View issue details on GitHub or Gitea
|
|
# Usage: issue-view.sh -i <issue_number>
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/detect-platform.sh"
|
|
|
|
# Parse arguments
|
|
ISSUE_NUMBER=""
|
|
|
|
# get_remote_host and get_gitea_token are provided by detect-platform.sh
|
|
|
|
gitea_issue_view_api() {
|
|
local host repo token url
|
|
host=$(get_remote_host) || {
|
|
echo "Error: could not determine remote host for API fallback" >&2
|
|
return 1
|
|
}
|
|
repo=$(get_repo_info) || {
|
|
echo "Error: could not determine repo owner/name for API fallback" >&2
|
|
return 1
|
|
}
|
|
token=$(get_gitea_token "$host") || {
|
|
echo "Error: Gitea token not found for API fallback (set GITEA_TOKEN or configure ~/.git-credentials)" >&2
|
|
return 1
|
|
}
|
|
|
|
url="https://${host}/api/v1/repos/${repo}/issues/${ISSUE_NUMBER}"
|
|
if command -v python3 >/dev/null 2>&1; then
|
|
curl -fsS -H "User-Agent: curl/8" -H "Authorization: token ${token}" "$url" | python3 -m json.tool
|
|
else
|
|
curl -fsS -H "User-Agent: curl/8" -H "Authorization: token ${token}" "$url"
|
|
fi
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-i|--issue)
|
|
ISSUE_NUMBER="$2"
|
|
shift 2
|
|
;;
|
|
-h|--help)
|
|
echo "Usage: issue-view.sh -i <issue_number>"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " -i, --issue Issue number (required)"
|
|
echo " -h, --help Show this help"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "$ISSUE_NUMBER" ]]; then
|
|
echo "Error: Issue number is required (-i)"
|
|
exit 1
|
|
fi
|
|
|
|
detect_platform >/dev/null
|
|
|
|
if [[ "$PLATFORM" == "github" ]]; then
|
|
gh issue view "$ISSUE_NUMBER"
|
|
elif [[ "$PLATFORM" == "gitea" ]]; then
|
|
if command -v tea >/dev/null 2>&1; then
|
|
if tea issue "$ISSUE_NUMBER" $(get_gitea_repo_args); then
|
|
exit 0
|
|
fi
|
|
echo "Warning: tea issue view failed, trying Gitea API fallback..." >&2
|
|
{ declare -F explain_tea_user_does_not_exist >/dev/null && explain_tea_user_does_not_exist; } || true
|
|
fi
|
|
gitea_issue_view_api
|
|
else
|
|
echo "Error: Unknown platform"
|
|
exit 1
|
|
fi
|