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

Method resolveProjectTrunkBranch

src/node/services/workspaceService.ts:3435–3468  ·  view source on GitHub ↗
(projectPath: string)

Source from the content-addressed store, hash-verified

3433 initLogger = this.createInitLogger(workspaceId);
3434
3435 const resolveProjectTrunkBranch = async (projectPath: string): Promise<string> => {
3436 if (isLocalRuntime) {
3437 return normalizedPreferredTrunkBranch ?? "";
3438 }
3439
3440 if (!normalizedPreferredTrunkBranch) {
3441 const localBranches = await listLocalBranches(projectPath);
3442 return detectDefaultTrunkBranch(projectPath, localBranches);
3443 }
3444
3445 try {
3446 const localBranches = await listLocalBranches(projectPath);
3447 if (localBranches.includes(normalizedPreferredTrunkBranch)) {
3448 return normalizedPreferredTrunkBranch;
3449 }
3450
3451 const detectedTrunkBranch = await detectDefaultTrunkBranch(projectPath, localBranches);
3452 log.debug("Requested multi-project trunk branch missing; using detected branch", {
3453 projectPath,
3454 requestedTrunkBranch: normalizedPreferredTrunkBranch,
3455 detectedTrunkBranch,
3456 });
3457 return detectedTrunkBranch;
3458 } catch (error: unknown) {
3459 // When branch discovery is unavailable, preserve the caller-provided branch.
3460 // This mirrors single-project create() behavior for non-local runtimes.
3461 log.debug("Failed to detect per-project trunk branch; using requested branch", {
3462 projectPath,
3463 requestedTrunkBranch: normalizedPreferredTrunkBranch,
3464 error: getErrorMessage(error),
3465 });
3466 return normalizedPreferredTrunkBranch;
3467 }
3468 };
3469 const projectRuntimeEntries = normalizedProjects.map((project) => ({
3470 project,
3471 runtime: createRuntime(finalRuntimeConfig, {

Callers

nothing calls this directly

Calls 4

listLocalBranchesFunction · 0.90
detectDefaultTrunkBranchFunction · 0.90
getErrorMessageFunction · 0.90
debugMethod · 0.80

Tested by

no test coverage detected