Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions apps/host/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,20 @@ const REVIEWS: Record<string, GithubPull["review"]> = {
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<GithubPull | null> {
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",
Expand All @@ -435,10 +440,11 @@ export async function pull(repo: string, branch: string): Promise<GithubPull | n
"--state",
"all",
"--limit",
"1",
"30",
"--json",
`${FIELDS},isDraft,statusCheckRollup,headRefOid,reviewDecision`,
`${FIELDS},isDraft,statusCheckRollup,headRefOid,reviewDecision,isCrossRepository`,
]);
const value = found.find((candidate) => !candidate.isCrossRepository);
if (!value) return null;
const review = REVIEWS[value.reviewDecision];
return {
Expand Down