From 994d493e08b393cbf683ca881cb2262497ebf2d0 Mon Sep 17 00:00:00 2001 From: Shawn Morreau Date: Wed, 10 Dec 2025 13:13:26 -0500 Subject: [PATCH] add branch logic mcp tool --- mcp/git.ts | 5 +++-- utils/errorReport.ts | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mcp/git.ts b/mcp/git.ts index fb87e15..adec415 100644 --- a/mcp/git.ts +++ b/mcp/git.ts @@ -30,8 +30,9 @@ export const CreateBranchTool = tool({ // fetch base branch to ensure we're up to date $("git", ["fetch", "origin", baseBranch, "--depth=1"]); - // checkout base branch - $("git", ["checkout", baseBranch]); + // checkout base branch, ensuring it matches the remote version + // -B creates or resets the branch to match origin/baseBranch + $("git", ["checkout", "-B", baseBranch, `origin/${baseBranch}`]); // create and checkout new branch $("git", ["checkout", "-b", branchName]); diff --git a/utils/errorReport.ts b/utils/errorReport.ts index 7470687..a2b3f95 100644 --- a/utils/errorReport.ts +++ b/utils/errorReport.ts @@ -1,6 +1,6 @@ -import { log } from "./cli.ts"; import { reportProgress } from "../mcp/comment.ts"; import { getMcpContext } from "../mcp/shared.ts"; +import { log } from "./cli.ts"; /** * Check if MCP context is initialized (i.e., MCP server has started) @@ -37,9 +37,7 @@ export async function reportErrorToComment({ await reportProgress({ body: formattedError }); } catch (reportError) { // log but don't throw - we don't want error reporting to fail the workflow - const errorMessage = - reportError instanceof Error ? reportError.message : String(reportError); + const errorMessage = reportError instanceof Error ? reportError.message : String(reportError); log.warning(`failed to report error to comment: ${errorMessage}`); } } -