* Resolve the bundle staging ref for the trunk branch. * Returns refs/mux-bundle/ if it exists, otherwise falls back * to the first available ref under refs/mux-bundle/ (handles main vs master * mismatches). Returns null if no bundle refs exist.
(
baseRepoPathArg: string,
trunkBranch: string,
abortSignal?: AbortSignal
)
| 1526 | * mismatches). Returns null if no bundle refs exist. |
| 1527 | */ |
| 1528 | private async resolveBundleTrunkRef( |
| 1529 | baseRepoPathArg: string, |
| 1530 | trunkBranch: string, |
| 1531 | abortSignal?: AbortSignal |
| 1532 | ): Promise<string | null> { |
| 1533 | // Preferred: exact match for the expected trunk branch. |
| 1534 | const preferredRef = `${BUNDLE_REF_PREFIX}${trunkBranch}`; |
| 1535 | const check = await execBuffered( |
| 1536 | this, |
| 1537 | `git -C ${baseRepoPathArg} rev-parse --verify ${shescape.quote(preferredRef)}`, |
| 1538 | { cwd: "/tmp", timeout: 10, abortSignal } |
| 1539 | ); |
| 1540 | if (check.exitCode === 0) { |
| 1541 | return preferredRef; |
| 1542 | } |
| 1543 | |
| 1544 | // Fallback: pick the first ref under refs/mux-bundle/ (handles main↔master mismatch). |
| 1545 | const listResult = await execBuffered( |
| 1546 | this, |
| 1547 | `git -C ${baseRepoPathArg} for-each-ref --format='%(refname)' ${BUNDLE_REF_PREFIX} --count=1`, |
| 1548 | { cwd: "/tmp", timeout: 10, abortSignal } |
| 1549 | ); |
| 1550 | const fallbackRef = listResult.stdout.trim(); |
| 1551 | if (listResult.exitCode === 0 && fallbackRef.length > 0) { |
| 1552 | log.info(`Bundle trunk ref mismatch: expected ${preferredRef}, using ${fallbackRef}`); |
| 1553 | return fallbackRef; |
| 1554 | } |
| 1555 | |
| 1556 | return null; |
| 1557 | } |
| 1558 | |
| 1559 | private async remoteTrackingBranchExists( |
| 1560 | baseRepoPathArg: string, |
no test coverage detected