diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-21 21:14:52 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-21 21:14:52 -0500 |
| commit | ab3a24c51efefedd5fb2c9603baa254360810c28 (patch) | |
| tree | 5cbef9fe4c4759d1afd3582bfd7d7ef5fcca50a2 /Omni | |
| parent | 382da4c19a4fa2e294d780ac9c39d5119b5323f1 (diff) | |
fix(agent): robust git rebase handling
Amp-Thread-ID:
https://ampcode.com/threads/T-79499d9e-f4f4-40de-893c-524c32a45483
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Agent/Git.hs | 13 |
1 files changed, 11 insertions, 2 deletions
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] |
