summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
Diffstat (limited to 'Omni')
-rw-r--r--Omni/Agent/Git.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs
index f4a7de5..60e6709 100644
--- a/Omni/Agent/Git.hs
+++ b/Omni/Agent/Git.hs
@@ -25,8 +25,8 @@ import Omni.Test ((@=?))
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.IO.Temp as Temp
import qualified System.Process as Process
main :: IO ()
@@ -167,7 +167,7 @@ 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}
@@ -178,7 +178,15 @@ commit :: FilePath -> Text -> IO ()
commit repo msg = do
Log.info ["git", "commit", msg]
git repo ["add", "."]
- git repo ["commit", "-m", Text.unpack msg]
+
+ -- Check for changes before committing to avoid error
+ let checkCmd = (Process.proc "git" ["diff", "--cached", "--quiet"]) {Process.cwd = Just repo}
+ (code, _, _) <- Process.readCreateProcessWithExitCode checkCmd ""
+
+ case code of
+ Exit.ExitSuccess -> Log.warn ["git", "nothing to commit", "skipping"]
+ Exit.ExitFailure 1 -> git repo ["commit", "-m", Text.unpack msg]
+ Exit.ExitFailure c -> panic <| "git diff failed with code " <> show c
createBranch :: FilePath -> Text -> IO ()
createBranch repo branch = do