Repository navigation
Require outside pull requests to close an open issue - #6189
Merged
Merged
Conversation
ymichael
force-pushed
the
bb/define-contribution-guidelines-thr_zc5q95yveb
branch
2 times, most recently
from
October 23, 2026 22:14
bf9e4d0 to
9a94dbd
Compare
The PR gate now closes pull requests from authors outside the bb team that do not close an open issue in this repo, and reopens them once the author links one. Its close comment lists each unmet requirement with the next step, and CONTRIBUTING.md documents the requirement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/define-contribution-guidelines-thr_zc5q95yveb
branch
from
October 23, 2026 22:46
40dd850 to
f41085e
Compare
This was referenced Oct 23, 2026
ymichael
added a commit
that referenced
this pull request
Oct 23, 2026
…#6197) ## Human comments ## What was wrong The linked-issue check from #6189 exempts authors whose `author_association` is `OWNER` or `MEMBER`. For an org member with private membership, `pull_request_target` reports `COLLABORATOR`. So maintainer pull requests from branches in this repository were closed with `needs-issue`. #6195 was closed this way: run 40039656279 logged `PR_ASSOCIATION: COLLABORATOR` and `HEAD_REPO: get-bb/bb`. Details in #6196. ## What changed `.github/workflows/pr-gate.yml` now runs the linked-issue check only when the head repository is not this repository. - **Same-repo pull requests:** only accounts with write access can push branches here, so these are exempt whatever the author's membership visibility. - **Fork pull requests:** handled exactly as before. Approval, maintainer edits and the issue requirement are unchanged. - **Closed `needs-issue` same-repo pull requests:** an edit now reopens them, because the `edited` path uses the same check. That covers #6195. `CONTRIBUTING.md` already describes the rule as "pull requests from outside the bb team", so it needs no change. ## How you verified - **Cause:** confirmed from the gate run log for #6195: `PR_ASSOCIATION: COLLABORATOR` and `HEAD_REPO: get-bb/bb`. - **Org membership:** `gh api orgs/get-bb/memberships/ymichael` reports an active admin, and `public_members` returns 404. - **Workflow file:** it still parses as YAML. The change is one extra condition on the existing `issue_missing` guard. Fixes #6196 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 24, 2026
… check (#6200) ## Human comments ## What was wrong Maintainers had no way to exempt a pull request from the PR gate's linked-issue requirement (#6189). Reopening one by hand sends a `reopened` event, the gate runs again, finds no linked issue, and closes it again. #6198 is an example. Separately, GitHub reports `maintainer_can_modify: false` on every closed pull request. #6198 had `MAINTAINER_CAN_MODIFY: true` in its `opened` run (40040917882) and reports `false` now, and every closed fork PR in the repo shows `false`. When the gate re-checked a closed `needs-issue` PR after an edit, it read that stale value as "maintainer edits off" and wouldn't reopen it. So "this pull request reopens on its own once you save the description" probably never worked for PRs from personal forks. ## What changed `.github/workflows/pr-gate.yml`: - **`skip-issue-check` label:** when the label is present, the linked-issue check is skipped. The gate now also runs on `labeled` events. Adding this label to a closed `needs-issue` PR goes through the same re-check as editing its description: the gate reopens the PR if the author is approved and maintainer edits were on. Other labels are ignored. Only accounts with triage access or higher can add labels, so contributors can't exempt themselves. - **`needs-maintainer-edits` label:** when the gate closes a PR because "Allow edits by maintainers" is off, it now adds this label. The re-check after an edit or label reads this label instead of the stale `maintainer_can_modify`. On `opened` and `reopened`, the gate still reads `maintainer_can_modify` as before. PRs closed for edits-off before this change don't have the label, so a re-check could reopen one of them. `CONTRIBUTING.md`: documents the maintainer exemption under "Linked Issue". I created the `skip-issue-check` label in the repo. ## How you verified I pulled the `run` script out of the workflow, checked it with `bash -n`, and ran it against a stubbed `gh` in eight scenarios. Each produced the expected `gh pr` calls: - opened with no issue → closed with `needs-issue` - `skip-issue-check` added to a closed PR (with the stale `maintainer_can_modify=false`) → reopened - some other label added → no action - description edited with `Fixes #N` on a closed PR (stale `false`) → reopened - `skip-issue-check` added, but the PR has `needs-maintainer-edits` → stays closed - reopened by hand with `skip-issue-check` → stays open - `skip-issue-check` added, but the author is not approved → stays closed - opened with edits off → closed with `needs-maintainer-edits` None of this has run on real GitHub events yet. `pull_request_target` takes effect only after merge, and #6198 is the first real case. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
About two thirds of recent fork pull requests (47 of 72 since Oct 19) referenced no issue, including feature and UI changes that CONTRIBUTING.md says need sign-off on an issue first. Nothing enforced this: the PR gate checked only contributor approval and "Allow edits by maintainers". Its close comment for authors who weren't approved was also hard to follow ("now closes on its own", "can reopen"). The
needs-approvallabel it tried to add does not exist in the repo, so thatgh pr editfailed silently every time.What changed
.github/workflows/pr-gate.yml: onopenedandreopened, PRs from authors who are not OWNER/MEMBER and not bots must close an open issue in this repo (GraphQLclosingIssuesReferences). Failing PRs are closed and labelledneeds-issue.synchronizeskips the issue check, so maintainers can push to contributor branches without closing them. A neweditedtrigger reopens a closedneeds-issuePR once an approved author links an issue (retrying the lookup a few times for link lag). The close comment now lists each requirement the PR misses (approval, linked issue, maintainer edits), with the next step for each. The gate creates theneeds-approval/needs-issuelabels on first use.CONTRIBUTING.md: lists the three requirements up front, adds a Linked Issue section that explains why the issue is required, and tells bug fixers to file and link an issue first..github/PULL_REQUEST_TEMPLATE.md: marksFixes #as required for outside contributors.packages/scripts/test/pr-approval-workflows.test.ts: follows the renamed gate step and new comment text, and adds a case table for the issue check (unlinked/linked, members, owners,synchronize, and theeditedreopen path).Open PRs that already lack an issue are only affected if someone reopens them. A PR the workflow reopens with
GITHUB_TOKENdoes not start new CI runs, but its existing head checks remain.How you verified
pnpm exec turbo run test lint typecheck --filter=@bb/scriptspasses (257 tests). Extracted the step script from the workflow with js-yaml and ran it with a stubbedghthrough 12 scenarios: new author with and without an issue, approved author with and without an issue,synchronize(no issue check), member, bot, edits off,editedon an open PR (no-op), andeditedon a closedneeds-issuePR when the issue is now linked (reopens), still missing (four lookups, no action), and when the author is not approved (no action). Checked that the labels, the close/reopen calls, and the comment text matched in each case. Theeditedevent on closed PRs has not been exercised on GitHub yet.🤖 Generated with Claude Code