()
| 487 | |
| 488 | const dryRun = options.dryRun === true; |
| 489 | const stopOnConflict = options.stopOnConflict === true; |
| 490 | const hasExplicitWorkspaceIds = Array.isArray(options.workspaceIds); |
| 491 | const requestedWorkspaceIds = hasExplicitWorkspaceIds |
| 492 | ? [...new Set(options.workspaceIds)] |
| 493 | : undefined; |
| 494 | const requestedCount = requestedWorkspaceIds?.length ?? initialContext.workspaces.length; |
| 495 | |
| 496 | const run = async (): Promise<MergeTeamRunMembersResponse> => { |
| 497 | const context = await this.loadTeamRunMergeableContext(teamRunId); |
| 498 | const response = await this.buildMergeableWorkspacesResponse(context); |
| 499 | const results: MergeTeamRunMemberResult[] = []; |
| 500 | const selected: MergeableWorkspaceItem[] = []; |
| 501 | |
| 502 | if (requestedWorkspaceIds) { |
| 503 | const itemsById = new Map(response.workspaces.map((item) => [item.workspaceId, item])); |
| 504 | for (const workspaceId of requestedWorkspaceIds) { |
| 505 | const item = itemsById.get(workspaceId); |
| 506 | if (item) { |
| 507 | selected.push(item); |
| 508 | } else { |
| 509 | results.push({ |
| 510 | workspaceId, |
| 511 | ownerMemberId: null, |
| 512 | status: 'SKIPPED', |
| 513 | code: 'INVALID_WORKSPACE_STATE', |
| 514 | message: 'Workspace is not a mergeable dedicated TeamRun child workspace', |
| 515 | }); |
| 516 | } |
| 517 | } |
| 518 | } else { |
| 519 | selected.push(...response.workspaces); |
| 520 | } |
| 521 | |
| 522 | for (const item of selected) { |
| 523 | if (item.status === WorkspaceStatus.MERGED) { |
| 524 | results.push({ |
| 525 | workspaceId: item.workspaceId, |
| 526 | ownerMemberId: item.owner.memberId, |
| 527 | status: dryRun ? 'ALREADY_MERGED' : 'ALREADY_MERGED', |
| 528 | sha: item.headSha ?? undefined, |
| 529 | }); |
| 530 | continue; |
| 531 | } |
| 532 | |
| 533 | if (!item.mergeReady) { |
| 534 | const firstBlocking = item.blockers.find((entry) => entry.severity === 'BLOCKING') ?? item.blockers[0]; |
| 535 | results.push({ |
| 536 | workspaceId: item.workspaceId, |
| 537 | ownerMemberId: item.owner.memberId, |
| 538 | status: 'SKIPPED', |
| 539 | code: firstBlocking?.code ?? 'WORKSPACE_NOT_ACTIVE', |
| 540 | message: firstBlocking?.message ?? 'Workspace is not ready to merge', |
| 541 | blockers: item.blockers, |
| 542 | }); |
| 543 | continue; |
| 544 | } |
| 545 | |
| 546 | if (dryRun) { |
nothing calls this directly
no test coverage detected