Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 9cf3e65

Browse files
committed
ci
1 parent e0b60d9 commit 9cf3e65

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

script/beta.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ interface PR {
55
title: string
66
}
77

8+
interface Repo {
9+
nameWithOwner: string
10+
}
11+
12+
interface HeadRepo {
13+
nameWithOwner: string
14+
}
15+
16+
interface PRHead {
17+
headRefName: string
18+
headRepository: HeadRepo
19+
}
20+
821
async function main() {
922
console.log("Fetching open contributor PRs...")
1023

@@ -16,6 +29,12 @@ async function main() {
1629
const prs: PR[] = JSON.parse(prsResult.stdout)
1730
console.log(`Found ${prs.length} open contributor PRs`)
1831

32+
const repoResult = await $`gh repo view --json nameWithOwner`.nothrow()
33+
if (repoResult.exitCode !== 0) {
34+
throw new Error(`Failed to fetch repo info: ${repoResult.stderr}`)
35+
}
36+
const repo: Repo = JSON.parse(repoResult.stdout)
37+
1938
console.log("Fetching latest dev branch...")
2039
const fetchDev = await $`git fetch origin dev`.nothrow()
2140
if (fetchDev.exitCode !== 0) {
@@ -34,9 +53,18 @@ async function main() {
3453
for (const pr of prs) {
3554
console.log(`\nProcessing PR #${pr.number}: ${pr.title}`)
3655

37-
// Get the diff from GitHub
56+
const headResult = await $`gh pr view ${pr.number} --json headRefName,headRepository`.nothrow()
57+
if (headResult.exitCode !== 0) {
58+
console.log(` Failed to get head info`)
59+
skipped.push({ number: pr.number, reason: `Failed to get head info: ${headResult.stderr}` })
60+
continue
61+
}
62+
const head: PRHead = JSON.parse(headResult.stdout)
63+
64+
// Get the diff from GitHub compare API
3865
console.log(` Getting diff...`)
39-
const diffResult = await $`gh pr diff ${pr.number}`.nothrow()
66+
const compare = `${repo.nameWithOwner}/compare/dev...${head.headRepository.nameWithOwner}:${head.headRefName}`
67+
const diffResult = await $`gh api -H Accept:application/vnd.github.v3.diff repos/${compare}`.nothrow()
4068
if (diffResult.exitCode !== 0) {
4169
console.log(` Failed to get diff`)
4270
skipped.push({ number: pr.number, reason: `Failed to get diff: ${diffResult.stderr}` })
@@ -80,7 +108,7 @@ async function main() {
80108
const commitMsg = `Apply PR #${pr.number}: ${pr.title}`
81109
const commit = await $`git commit -m ${commitMsg}`.nothrow()
82110
if (commit.exitCode !== 0) {
83-
console.log(` Failed to commit`)
111+
console.log(` Failed to commit: ${commit.stderr}`)
84112
await $`git checkout -- .`.nothrow()
85113
await $`git clean -fd`.nothrow()
86114
skipped.push({ number: pr.number, reason: `Commit failed: ${commit.stderr}` })

0 commit comments

Comments
 (0)