From eb847c03f65e110ffd19d2d08b8150791e08bc2c Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Wed, 13 May 2026 22:05:26 -0400 Subject: [PATCH] Notify on all git operation failures, not just merge conflicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generalize notifyConflict into notifyUser that accepts an arbitrary title and body. Call notify-send for commit failures and pull failures in addition to the existing merge-conflict notification. "Nothing to commit" is intentionally excluded — it is an expected no-op, not a failure. --- src/Converge.hs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Converge.hs b/src/Converge.hs index 6d1ceb6..b3de44f 100644 --- a/src/Converge.hs +++ b/src/Converge.hs @@ -28,7 +28,7 @@ module Converge ( checkIndicatorFiles, -- * Notifications - notifyConflict, + notifyUser, -- * File filtering isGitIgnored, @@ -266,8 +266,11 @@ syncRepo opts logger repo = do | "nothing to commit" `T.isInfixOf` commitOut || "nothing to commit" `T.isInfixOf` commitErr -> logRepo logger repo "nothing to commit (working tree clean)" - | otherwise -> + | otherwise -> do logRepo logger repo ("commit FAILED (exit " <> T.pack (show commitCode) <> "): " <> T.strip (commitOut <> commitErr)) + notifyUser opts + "Converge: Commit Failed" + ("Commit failed in " <> rcPath repo <> " (exit " <> show commitCode <> ")") -- Pull logRepo logger repo ("pulling " <> rcRemote repo <> "/" <> rcBranch repo) (pullCode, pullOut, pullErr) <- gitPull repo @@ -277,14 +280,19 @@ syncRepo opts logger repo = do if T.null trimmed then logRepo logger repo "pull: already up to date" else logRepo logger repo ("pull succeeded:\n" <> trimmed) - _ -> + _ -> do logRepo logger repo ("pull FAILED (exit " <> T.pack (show pullCode) <> "): " <> T.strip (pullOut <> pullErr)) + notifyUser opts + "Converge: Pull Failed" + ("Pull failed in " <> rcPath repo <> " (exit " <> show pullCode <> ")") -- Conflict check conflicted <- hasConflicts (rcPath repo) if conflicted then do logRepo logger repo "*** MERGE CONFLICT detected! ***" - notifyConflict opts repo + notifyUser opts + "Converge: Merge Conflict" + ("A merge conflict occurred in " <> rcPath repo <> ". Manual resolution required.") else logRepo logger repo "sync complete, no conflicts" ---------------------------------------------------------------------- @@ -361,16 +369,11 @@ checkIndicatorFiles gitDir = do -- Notifications ---------------------------------------------------------------------- --- | Send a desktop notification about a merge conflict. -notifyConflict :: Options -> RepoConfig -> IO () -notifyConflict opts repo = do +-- | Send a desktop notification. +notifyUser :: Options -> String -> String -> IO () +notifyUser opts title body = do let cmd = T.unpack (optNotifyCmd opts) - title = "Converge: Merge Conflict" - body = - "A merge conflict occurred in " - <> T.pack (rcPath repo) - <> ". Manual resolution required." - _ <- spawnProcess cmd ["--urgency=critical", title, T.unpack body] + _ <- spawnProcess cmd ["--urgency=critical", title, body] pure () ----------------------------------------------------------------------