MCPcopy Index your code
hub / github.com/dmno-dev/bumpy / resolveTargetPrNumber

Function resolveTargetPrNumber

packages/bumpy/src/commands/ci.ts:345–366  ·  view source on GitHub ↗
(rootDir: string)

Source from the content-addressed store, hash-verified

343 * normal PR detection used by `ci check`.
344 */
345export function resolveTargetPrNumber(rootDir: string): string | null {
346 if (process.env.GITHUB_EVENT_NAME === 'workflow_run') {
347 const event = readGitHubEventPayload();
348 const headSha = event?.workflow_run?.head_sha;
349 const repo = process.env.GITHUB_REPOSITORY;
350 // Sanitize both before they reach the gh api path: a 40-hex SHA and an owner/repo slug.
351 if (headSha && /^[0-9a-f]{40}$/i.test(headSha) && repo && /^[\w.-]+\/[\w.-]+$/.test(repo)) {
352 const out = tryRunArgs(
353 ['gh', 'api', `repos/${repo}/commits/${headSha}/pulls`, '--jq', '.[] | select(.state == "open") | .number'],
354 { cwd: rootDir },
355 );
356 return (
357 out
358 ?.split('\n')
359 .map((l) => l.trim())
360 .find((l) => /^\d+$/.test(l)) ?? null
361 );
362 }
363 return null;
364 }
365 return detectPrNumber();
366}
367
368// ---- ci plan ----
369

Callers 2

ci-comment.test.tsFile · 0.90
ciCommentCommandFunction · 0.85

Calls 3

tryRunArgsFunction · 0.90
readGitHubEventPayloadFunction · 0.85
detectPrNumberFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…