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

Method fastForwardToOrigin

src/node/runtime/SSHRuntime.ts:3060–3095  ·  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,
    abortSignal?: AbortSignal,
    nhp = ""
  )

Source from the content-addressed store, hash-verified

3058 * Best-effort operation for existing branches that may be behind origin.
3059 */
3060 private async fastForwardToOrigin(
3061 workspacePath: string,
3062 trunkBranch: string,
3063 initLogger: InitLogger,
3064 abortSignal?: AbortSignal,
3065 nhp = ""
3066 ): Promise<void> {
3067 try {
3068 initLogger.logStep("Fast-forward merging...");
3069
3070 const mergeCmd = `${nhp}git merge --ff-only origin/${shescape.quote(trunkBranch)}`;
3071 const mergeStream = await this.exec(mergeCmd, {
3072 cwd: workspacePath,
3073 timeout: 60, // 1 minute for fast-forward merge
3074 abortSignal,
3075 });
3076
3077 const [mergeStderr, mergeExitCode] = await Promise.all([
3078 streamToString(mergeStream.stderr),
3079 mergeStream.exitCode,
3080 ]);
3081
3082 if (mergeExitCode !== 0) {
3083 // Fast-forward not possible (diverged branches) - just warn
3084 initLogger.logStderr(
3085 `Note: Fast-forward skipped (${mergeStderr || "branches diverged"}), using local branch state`
3086 );
3087 } else {
3088 initLogger.logStep("Fast-forwarded to latest origin successfully");
3089 }
3090 } catch (error) {
3091 // Non-fatal: log and continue
3092 const errorMsg = getErrorMessage(error);
3093 initLogger.logStderr(`Note: Fast-forward failed (${errorMsg}), using local branch state`);
3094 }
3095 }
3096
3097 async renameWorkspace(
3098 projectPath: string,

Callers 1

Calls 5

streamToStringFunction · 0.90
getErrorMessageFunction · 0.90
logStepMethod · 0.80
logStderrMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected