diff options
| author | Omni Worker <bot@omni.agent> | 2025-11-22 04:43:04 -0500 |
|---|---|---|
| committer | Omni Worker <bot@omni.agent> | 2025-11-22 04:43:04 -0500 |
| commit | d97fe0e79e2970f0f58c889020d68f202ed11cdd (patch) | |
| tree | 9dace36153094d2a43b852ffd170ef0661927111 /Omni | |
| parent | 89dc7db5c898374ce1c41b83d3d41ee6a748cb49 (diff) | |
refactor(agent): use 'git sync' instead of rebase
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 | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs index a2009b2..a33be23 100644 --- a/Omni/Agent/Git.hs +++ b/Omni/Agent/Git.hs @@ -25,7 +25,6 @@ import Omni.Test ((@=?)) import qualified Omni.Test as Test import qualified System.Directory as Directory import qualified System.Exit as Exit -import System.FilePath ((</>)) import qualified System.IO.Temp as Temp import qualified System.Process as Process @@ -149,30 +148,18 @@ syncWithLive repo = do Log.info ["git", "syncing with live"] -- 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 "" + -- Try sync (branchless sync), if fail, panic + -- This replaces manual rebase and handles stack movement + let cmd = (Process.proc "git" ["sync"]) {Process.cwd = Just repo} + (code, out, err) <- Process.readCreateProcessWithExitCode cmd "" case code of Exit.ExitSuccess -> pure () Exit.ExitFailure _ -> do - Log.warn ["rebase failed, aborting", Text.pack err] - cleanupStaleRebase repo - panic "Sync with live failed (rebase conflict)" - -cleanupStaleRebase :: FilePath -> IO () -cleanupStaleRebase repo = do - -- 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 () + Log.warn ["git sync failed", Text.pack err] + Log.info [Text.pack out] + panic "Sync with live failed (git sync)" + + commit :: FilePath -> Text -> IO () commit repo msg = do |
