MCPcopy
hub / github.com/coder/mux / fetchMergeQueueEntry

Method fetchMergeQueueEntry

src/browser/stores/PRStatusStore.ts:526–578  ·  view source on GitHub ↗

* Fetch merge queue details via GraphQL. * Best-effort only: failures should not block normal PR status updates.

(
    workspaceId: string,
    prLink: { owner: string; repo: string; number: number }
  )

Source from the content-addressed store, hash-verified

524 * Best-effort only: failures should not block normal PR status updates.
525 */
526 private async fetchMergeQueueEntry(
527 workspaceId: string,
528 prLink: { owner: string; repo: string; number: number }
529 ): Promise<MergeQueueEntry | null> {
530 if (!this.client || !this.isActive) {
531 return null;
532 }
533
534 try {
535 const result = await this.client.workspace.executeBash({
536 workspaceId,
537 script: [
538 "gh api graphql",
539 `-f query='${MERGE_QUEUE_QUERY}'`,
540 `-f owner='${prLink.owner}'`,
541 `-f repo='${prLink.repo}'`,
542 `-F number=${prLink.number}`,
543 "2>/dev/null",
544 ].join(" "),
545 // gh requires the runtime environment for devcontainer workspaces where
546 // the CLI / auth may only exist inside the container.
547 options: repoRootBashOptions(10),
548 });
549
550 if (!this.isActive || !result.success || !result.data.success) {
551 return null;
552 }
553
554 if (!result.data.output) {
555 return null;
556 }
557
558 const parsed = JSON.parse(result.data.output) as Record<string, unknown>;
559 const data = parsed.data;
560 if (typeof data !== "object" || data === null) {
561 return null;
562 }
563
564 const repository = (data as Record<string, unknown>).repository;
565 if (typeof repository !== "object" || repository === null) {
566 return null;
567 }
568
569 const pullRequest = (repository as Record<string, unknown>).pullRequest;
570 if (typeof pullRequest !== "object" || pullRequest === null) {
571 return null;
572 }
573
574 return parseMergeQueueEntry((pullRequest as Record<string, unknown>).mergeQueueEntry);
575 } catch {
576 return null;
577 }
578 }
579
580 private shouldFetchWorkspace(entry: WorkspacePRCacheEntry | undefined, now: number): boolean {
581 if (!entry) return true;

Callers 1

Calls 4

repoRootBashOptionsFunction · 0.90
parseMergeQueueEntryFunction · 0.85
executeBashMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected