From 6ad88bf2454b692dc28d6fac6d65042e055ea529 Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Fri, 21 Nov 2025 22:02:43 -0500 Subject: fix(agent): check for existing branch before creating Amp-Thread-ID: https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483 Co-authored-by: Amp --- Omni/Agent/Worker.hs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Omni/Agent/Worker.hs') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index 59d576f..d201234 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -67,15 +67,21 @@ processTask worker task = do if currentBranch == taskBranch then Log.info ["worker", "resuming branch", taskBranch] else do - -- Determine base branch from dependencies - baseBranch <- findBaseBranch repo task - if baseBranch /= "live" + exists <- Git.branchExists repo taskBranch + if exists then do - Log.info ["worker", "basing", taskBranch, "on", baseBranch] - Git.checkout repo baseBranch - else Log.info ["worker", "basing", taskBranch, "on live"] - - Git.createBranch repo taskBranch + Log.info ["worker", "switching to existing branch", taskBranch] + Git.checkout repo taskBranch + else do + -- Determine base branch from dependencies + baseBranch <- findBaseBranch repo task + if baseBranch /= "live" + then do + Log.info ["worker", "basing", taskBranch, "on", baseBranch] + Git.checkout repo baseBranch + else Log.info ["worker", "basing", taskBranch, "on live"] + + Git.createBranch repo taskBranch -- Run Amp exitCode <- runAmp repo task -- cgit v1.2.3