diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-21 22:02:43 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-21 22:02:43 -0500 |
| commit | 6ad88bf2454b692dc28d6fac6d65042e055ea529 (patch) | |
| tree | f2396e2c237c40cf07a7749ec256cbe531a36c4a /Omni/Agent/Worker.hs | |
| parent | cab9f120d3b71d2e2d794b8ea6f2f685610dc34c (diff) | |
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 <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent/Worker.hs')
| -rw-r--r-- | Omni/Agent/Worker.hs | 22 |
1 files changed, 14 insertions, 8 deletions
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 |
