MCPcopy Index your code
hub / github.com/coder/mux / fastForwardToOrigin

Method fastForwardToOrigin

src/node/worktree/WorktreeManager.ts:338–362  ·  view source on GitHub ↗

* Fast-forward merge to latest origin/ after checkout. * Best-effort operation for existing branches that may be behind origin.

(
    workspacePath: string,
    trunkBranch: string,
    initLogger: InitLogger,
    noHooksEnv: GitExecOptions
  )

Source from the content-addressed store, hash-verified

336 * Best-effort operation for existing branches that may be behind origin.
337 */
338 private async fastForwardToOrigin(
339 workspacePath: string,
340 trunkBranch: string,
341 initLogger: InitLogger,
342 noHooksEnv: GitExecOptions
343 ): Promise<void> {
344 try {
345 initLogger.logStep("Fast-forward merging...");
346
347 using mergeProc = execFileAsync(
348 "git",
349 ["-C", workspacePath, "merge", "--ff-only", `origin/${trunkBranch}`],
350 noHooksEnv
351 );
352 await mergeProc.result;
353 initLogger.logStep("Fast-forwarded to latest origin successfully");
354 } catch (mergeError) {
355 if (isAbortError(mergeError, noHooksEnv?.signal)) {
356 throw mergeError;
357 }
358 // Fast-forward not possible (diverged branches) - just warn
359 const errorMsg = getErrorMessage(mergeError);
360 initLogger.logStderr(`Note: Fast-forward failed (${errorMsg}), using local branch state`);
361 }
362 }
363
364 async renameWorkspace(
365 projectPath: string,

Callers 1

createWorkspaceMethod · 0.95

Calls 5

execFileAsyncFunction · 0.90
getErrorMessageFunction · 0.90
logStepMethod · 0.80
logStderrMethod · 0.80
isAbortErrorFunction · 0.70

Tested by

no test coverage detected