From ab3a24c51efefedd5fb2c9603baa254360810c28 Mon Sep 17 00:00:00 2001 From: Omni Worker Date: Fri, 21 Nov 2025 21:14:52 -0500 Subject: fix(agent): robust git rebase handling Amp-Thread-ID: https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483 Co-authored-by: Amp --- Omni/Agent/Git.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Omni') diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs index 7717cee..1144774 100644 --- a/Omni/Agent/Git.hs +++ b/Omni/Agent/Git.hs @@ -149,16 +149,25 @@ syncWithLive repo = do -- git repo ["fetch", "origin", "live"] -- Optional -- Try rebase, if fail, abort + -- First, proactively cleanup any stale rebase state + cleanupStaleRebase repo + let cmd = (Process.proc "git" ["rebase", "live"]) {Process.cwd = Just repo} (code, _, err) <- Process.readCreateProcessWithExitCode cmd "" case code of Exit.ExitSuccess -> pure () Exit.ExitFailure _ -> do Log.warn ["rebase failed, aborting", Text.pack err] - let abort = (Process.proc "git" ["rebase", "--abort"]) {Process.cwd = Just repo} - _ <- Process.readCreateProcessWithExitCode abort "" + cleanupStaleRebase repo panic "Sync with live failed (rebase conflict)" +cleanupStaleRebase :: FilePath -> IO () +cleanupStaleRebase repo = do + -- Try to abort any in-progress rebase. Ignore failure (e.g. if no rebase in progress) + let abort = (Process.proc "git" ["rebase", "--abort"]) {Process.cwd = Just repo} + _ <- Process.readCreateProcessWithExitCode abort "" + pure () + commit :: FilePath -> Text -> IO () commit repo msg = do Log.info ["git", "commit", msg] -- cgit v1.2.3