diff --git a/.lane/memory/apps/host/src/github.ts/01M5JMZZF995AGBW0T463TMG57-gh-head-matches-a-branch-nam.md b/.lane/memory/apps/host/src/github.ts/01M5JMZZF995AGBW0T463TMG57-gh-head-matches-a-branch-nam.md new file mode 100644 index 00000000..843a8d7c --- /dev/null +++ b/.lane/memory/apps/host/src/github.ts/01M5JMZZF995AGBW0T463TMG57-gh-head-matches-a-branch-nam.md @@ -0,0 +1,12 @@ +--- +id: 01M5JMZZF995AGBW0T463TMG57 +anchor: function pull +created: 2026-10-22T20:31:43Z +norm: '1' +sig: 86063795bd4c903a +body_hash: 6bb86a7719dc73dc +raw_hash: e870bcc2d71cf57a +lines: 424-456 +--- + +gh --head matches a branch name in any fork; only same-repository pull requests are a channel's diff --git a/apps/host/src/github.ts b/apps/host/src/github.ts index 00690760..298642d9 100644 --- a/apps/host/src/github.ts +++ b/apps/host/src/github.ts @@ -416,15 +416,20 @@ const REVIEWS: Record = { REVIEW_REQUIRED: "required", }; -/** The newest pull request whose head is `branch`, or null when there is none. */ +/** + * The newest pull request from `branch` in the repository itself, or null when there is none. + * `--head` matches the branch name in any fork, and strangers open pull requests from their forks' + * `master` or `main`, so pull requests from other repositories never count as the channel's. + */ export async function pull(repo: string, branch: string): Promise { if (!branch || branch.startsWith("-")) throw new Error("Invalid branch name"); - const [value] = await gh< + const found = await gh< (Item & { isDraft: boolean; statusCheckRollup: Check[]; headRefOid: string; reviewDecision: string; + isCrossRepository: boolean; })[] >([ "pr", @@ -435,10 +440,11 @@ export async function pull(repo: string, branch: string): Promise !candidate.isCrossRepository); if (!value) return null; const review = REVIEWS[value.reviewDecision]; return {