⚡ perf(vscode): 摘修复用本地合并记录分组,列表改手风琴
This commit is contained in:
1 parent
cfabee08b7
commit
5284fc1730
8 files changed
+183
-221
No files matched your search
@@ -362,67 +362,6 @@ export async function getPullRequest(opts: {
|
||||
}
|
||||
}
|
||||
|
||||
export async function listClosedPullsPage(opts: {
|
||||
host: string
|
||||
token: string
|
||||
owner: string
|
||||
repo: string
|
||||
page: number
|
||||
}): Promise<Array<{ number: number, title: string, merged: boolean, mergeCommitSha: string | null }>> {
|
||||
const url = new URL(`${baseUrl(opts.host)}/repos/${opts.owner}/${opts.repo}/pulls`)
|
||||
url.searchParams.set('state', 'closed')
|
||||
url.searchParams.set('sort', 'recentupdate')
|
||||
url.searchParams.set('limit', String(PAGE_SIZE))
|
||||
url.searchParams.set('page', String(opts.page))
|
||||
const res = await fetch(url.toString(), { headers: authHeaders(opts.token) })
|
||||
await ensureOk(res)
|
||||
const batch = await res.json() as Array<{
|
||||
number?: unknown
|
||||
title?: unknown
|
||||
merged?: unknown
|
||||
merge_commit_sha?: unknown
|
||||
}>
|
||||
if (!Array.isArray(batch))
|
||||
return []
|
||||
return batch.map(p => ({
|
||||
number: typeof p.number === 'number' ? p.number : Number(p.number),
|
||||
title: typeof p.title === 'string' ? p.title : '',
|
||||
merged: p.merged === true,
|
||||
mergeCommitSha: typeof p.merge_commit_sha === 'string' && p.merge_commit_sha.length > 0
|
||||
? p.merge_commit_sha
|
||||
: null,
|
||||
}))
|
||||
}
|
||||
|
||||
export async function listPullRequestCommitShas(opts: {
|
||||
host: string
|
||||
token: string
|
||||
owner: string
|
||||
repo: string
|
||||
index: number
|
||||
}): Promise<string[]> {
|
||||
const out: string[] = []
|
||||
let page = 1
|
||||
while (true) {
|
||||
const url = new URL(`${baseUrl(opts.host)}/repos/${opts.owner}/${opts.repo}/pulls/${opts.index}/commits`)
|
||||
url.searchParams.set('limit', String(PAGE_SIZE))
|
||||
url.searchParams.set('page', String(page))
|
||||
const res = await fetch(url.toString(), { headers: authHeaders(opts.token) })
|
||||
await ensureOk(res)
|
||||
const batch = await res.json() as Array<{ sha?: unknown }>
|
||||
if (!Array.isArray(batch) || batch.length === 0)
|
||||
break
|
||||
for (const c of batch) {
|
||||
if (typeof c.sha === 'string' && c.sha.length > 0)
|
||||
out.push(c.sha)
|
||||
}
|
||||
if (batch.length < PAGE_SIZE)
|
||||
break
|
||||
page += 1
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
export async function getIssue(opts: {
|
||||
host: string
|
||||
token: string
|
||||
|
||||
Reference in new issue
Block a user