MCPcopy Create free account
hub / github.com/SIMARSINGHRAYAT/Gitzo / waitForMergeable

Function waitForMergeable

src/utils/github.ts:488–511  ·  view source on GitHub ↗
(
  token: string,
  owner: string,
  repo: string,
  pullNumber: number,
  maxAttempts = 15,
  pollInterval = 1000
)

Source from the content-addressed store, hash-verified

486 * Wait for a PR to become mergeable by polling its status.
487 */
488export async function waitForMergeable(
489 token: string,
490 owner: string,
491 repo: string,
492 pullNumber: number,
493 maxAttempts = 15,
494 pollInterval = 1000
495): Promise<{ mergeable: boolean; mergeable_state: string }> {
496 for (let attempt = 0; attempt < maxAttempts; attempt++) {
497 const res = await ghFetch(`/repos/${owner}/${repo}/pulls/${pullNumber}`, token);
498 if (!res.ok) {
499 if (attempt < maxAttempts - 1) { await sleep(pollInterval); continue; }
500 throw new Error(`Failed to check PR #${pullNumber} status: HTTP ${res.status}`);
501 }
502 const data = await res.json();
503
504 if (data.mergeable === null) { await sleep(pollInterval); continue; }
505 if (data.mergeable === true) {
506 return { mergeable: true, mergeable_state: data.mergeable_state || 'clean' };
507 }
508 return { mergeable: false, mergeable_state: data.mergeable_state || 'unknown' };
509 }
510 return { mergeable: false, mergeable_state: 'polling_timeout' };
511}
512
513/**
514 * Merge a PR with retries.

Callers 3

startYOLOBadgeWorkflowFunction · 0.90
startCreatingPRsFunction · 0.90
startCreatingPairsFunction · 0.90

Calls 2

ghFetchFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected