diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-21 21:28:07 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-21 21:28:07 -0500 |
| commit | 9224442f7f99059706384b3641f69e41c9633d64 (patch) | |
| tree | ea2347b1c10521dbec0f665538d10a5f3ce9db1b /Omni/Agent/Git.hs | |
| parent | cd839efe1bbdaa217009885da2e00d575da7ac00 (diff) | |
fix(agent): detect stale rebase before aborting
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/Git.hs')
| -rw-r--r-- | Omni/Agent/Git.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs index 1144774..f4a7de5 100644 --- a/Omni/Agent/Git.hs +++ b/Omni/Agent/Git.hs @@ -26,6 +26,7 @@ import qualified Omni.Test as Test import qualified System.Directory as Directory import qualified System.Exit as Exit import qualified System.IO.Temp as Temp +import System.FilePath ((</>)) import qualified System.Process as Process main :: IO () @@ -163,10 +164,15 @@ syncWithLive repo = do 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 () + -- Check if a rebase is in progress + rebaseMerge <- Directory.doesDirectoryExist (repo </> ".git/rebase-merge") + rebaseApply <- Directory.doesDirectoryExist (repo </> ".git/rebase-apply") + + when (rebaseMerge || rebaseApply) <| do + Log.warn ["git", "detected stale rebase", "aborting"] + let abort = (Process.proc "git" ["rebase", "--abort"]) {Process.cwd = Just repo} + _ <- Process.readCreateProcessWithExitCode abort "" + pure () commit :: FilePath -> Text -> IO () commit repo msg = do |
