framework tools/git: P1b — read-only viewers join the R1/R4 contract (pr-diff, pr-view, pr-metadata, pr-list)
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/manual/ci Pipeline was successful

usage_error contract (stderr + exit 2), strict option-like value
guards, missing -n checks; pr-list usage() default exit 2. Four suites
enrolled (population 93). Closes the viewer gap from the #1464 census:
carriers now 20 of the 22; remaining non-carriers are the deliberate
design-first class (ci-queue-wait, pr-merge, pr-ci-wait, mosaic-worktree).
This commit is contained in:
2026-08-29 15:01:06 -05:00
parent 635cb1f666
commit 9fd1baab68
9 changed files with 586 additions and 16 deletions
+16 -4
View File
@@ -13,21 +13,33 @@ OUTPUT_FILE=""
REPO_OVERRIDE=""
HOST_OVERRIDE=""
# Usage-error contract (R4): usage errors print to STDERR and exit 2,
# distinct from provider, credential, and verification failures (exit 1).
usage_error() {
echo "Error: $*" >&2
echo "Usage: pr-diff.sh -n <pr_number> [-r owner/repo] [--host host] [-o <output_file>] (see --help)" >&2
exit 2
}
while [[ $# -gt 0 ]]; do
case $1 in
-n|--number)
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
PR_NUMBER="$2"
shift 2
;;
-o|--output)
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
OUTPUT_FILE="$2"
shift 2
;;
-r|--repo)
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
REPO_OVERRIDE="$2"
shift 2
;;
--host)
[[ $# -ge 2 && "$2" != - && "$2" != --* && ! "$2" =~ ^-[[:alnum:]] ]] || usage_error "option $1 requires a value (option-like values are rejected; bare - is reserved)"
HOST_OVERRIDE="$2"
shift 2
;;
@@ -40,18 +52,18 @@ while [[ $# -gt 0 ]]; do
echo " --host Gitea host for --repo API calls (or set GITEA_HOST/GITEA_URL)"
echo " -o, --output Output file (optional, prints to stdout if omitted)"
echo " -h, --help Show this help"
echo ""
echo "Exit codes: 0 success; 2 usage error (stderr); 1 provider/credential failure."
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
usage_error "unknown option: $1"
;;
esac
done
if [[ -z "$PR_NUMBER" ]]; then
echo "Error: PR number is required (-n)" >&2
exit 1
usage_error "PR number is required (-n/--number)"
fi
if [[ -n "$REPO_OVERRIDE" ]]; then