MCPcopy Index your code
hub / github.com/anomalyco/opencode / ensureCleanupLabel

Function ensureCleanupLabel

script/github/close-prs.ts:274–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272}
273
274async function ensureCleanupLabel() {
275 const response = await fetch(
276 `https://api.github.com/repos/${repo.owner}/${repo.name}/labels/${encodeURIComponent(cleanupLabel)}`,
277 {
278 headers,
279 },
280 )
281 if (response.ok) return
282 if (response.status !== 404)
283 throw new Error(`Failed to check cleanup label: ${response.status} ${response.statusText}`)
284
285 await githubRequest(`/repos/${repo.owner}/${repo.name}/labels`, {
286 method: "POST",
287 body: JSON.stringify({
288 name: cleanupLabel,
289 color: "ededed",
290 description: "PR was closed by automated cleanup",
291 }),
292 })
293}
294
295async function githubRequest(path: string, init: RequestInit, attempt = 0): Promise<Response> {
296 const response = await fetch(path.startsWith("https://") ? path : `https://api.github.com${path}`, {

Callers 1

mainFunction · 0.85

Calls 2

githubRequestFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected