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