chore(scripts): add scripts/request-review.sh to formalize fork-PR reviewer pings#497
Closed
Senorespecial wants to merge 1 commit into
Closed
Conversation
4a735f3 to
e32b257
Compare
…viewer pings When this repo is opened from a fork (e.g. Senorespecial/Meridians-verse -> MERIDIAN-CITY/Meridians-verse), the fork-scoped gh token returns 403 on the direct paths that formally request reviewers (gh pr edit --add-reviewer returns GraphQL requestReviewsByLogin permission error; REST POST /pulls/:n/requested_reviewers returns 403). This script encapsulates the workaround that has been used manually on PR MERIDIAN-CITY#491 and PR MERIDIAN-CITY#495: try the direct paths first (works from upstream-write-token env), and on 403 fall back to posting a PR comment containing a ready-to-paste maintainer command plus a TL;DR for the human reviewer. The fallback comment is dedup-aware via a single DEDUP_MARKER shell constant used both for grep-marker-matching and as the comment-header text, so re-running the script on a PR with an existing fallback comment exits 3 without reposting. Also includes --help (prints the header docstring), --dry-run (logs what each gh call would do without side effects, exits 3 with no mutation), REQUEST_REVIEW_REPO envvar override, and documented exit codes (0/1/2/3) for downstream automation. No production code change; scripts/ is a new directory at the repo root.
e32b257 to
78ac295
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
scripts/request-review.sh(the fork-PR + token-403 reviewer-request workaround that was hand-rolled across PRs #491 and #495) plus a top-levelMakefilereciperequest-reviewand aCONTRIBUTING.mdone-liner exposing it, so future contributors find the script on day one without rediscovering the 403 dance.Files
scripts/request-review.sh(~178 lines, executable) — main artifact.Makefile— top-level umbrellamake request-review ARGS="..."recipe delegating to the script; includes amake helpso contributors can discover available recipes.CONTRIBUTING.md— one-line section pointing future contributors atmake request-review.Why
A fork-PR contributor bot can't
gh pr edit --add-reviewer— it returnsResource not accessible by integration(same constraint observed on PR #491). Until now each fork-PR hand-crafted the workaround in a comment. Codifying it in a tagged script + wiring it into the repo's tooling surface (Makefile + CONTRIBUTING one-liner) means any futurechore(ci): ...PR can just run:without re-deriving the 403 dance.
Flags
scripts/request-review.shexposes:--dry-run— echo what eachghcall would do without making any GitHub API mutations; exits 4.--report-json— emit one JSON summary line to stdout on every exit (suitable forjq .capture).--help | -h— print the header docstring and exit 0.Exit codes:
0direct success,1bad args,2fallback comment posted,3idempotent skip,4dry-run end.Polish rounds applied
--help(no hardcoded line range).>/dev/nullon Steps 1/2 (was2>&1 >&2, leaked run_gh's--dry-runechoes into stdout and contaminated JSON contract).--report-jsonin$@BEFORE the main flag-parse loop (so--typo --report-jsonemits JSON instead of 0 stdout lines).casestyle (consistency with main loop's flag-dispatch arms).emit_jsondefined BEFORE flag-parse loop (bash does NOT hoist function defs)._int_or_nonefor empty PR_NUMBER / exit_code (called from bad_args / unknown-flag early-exit paths).>&2(preserve gh stdout for operator visibility) vs Steps 1/2>/dev/null(suppress gh stdout to protect JSON contract).Sanity coverage
bash -nclean.make -n helpandmake -n request-review ARGS="..."echo without invoking.make request-review ARGS="--dry-run --report-json 495 Qoder-Undefined"runs the script end-to-end via the Makefile and produces correct JSON-on-stdout + dry-run notices on stderr. Manual test matrix covers:--help, no-args,--report-json --dry-run,--dry-run --report-json,--typo --report-json,--report-json --typo, multiple unknowns +--report-json,--typo --dry-runno-JSON,--report-json --typo --dry-run.