diff options
| -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] |
