From 3af8739ed1eefdb24d1eb42837b2dae13c2b411b Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 26 Nov 2025 06:04:51 -0500 Subject: Simplify worker to use lint --fix Task-Id: t-1o2g8gugkr1 --- Omni/Agent/Worker.hs | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'Omni') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index c5ee451..9a6a86f 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -94,36 +94,14 @@ processTask worker task = do AgentLog.updateActivity "Agent failed, retrying..." threadDelay (10 * 1000000) -- Sleep 10s --- | Run ormolu and hlint --refactor on changed files +-- | Run lint --fix to format and fix lint issues runFormatters :: FilePath -> IO (Either Text ()) runFormatters repo = do - -- Get list of changed .hs files - let diffCmd = (Process.proc "git" ["diff", "--name-only", "--cached", "HEAD"]) {Process.cwd = Just repo} - (_, diffOut, _) <- Process.readCreateProcessWithExitCode diffCmd "" - - -- Also get untracked files - let untrackedCmd = (Process.proc "git" ["ls-files", "--others", "--exclude-standard"]) {Process.cwd = Just repo} - (_, untrackedOut, _) <- Process.readCreateProcessWithExitCode untrackedCmd "" - - let changedFiles = Text.lines (Text.pack diffOut) ++ Text.lines (Text.pack untrackedOut) - allFiles = filter (Text.isSuffixOf ".hs") changedFiles - - if null allFiles - then pure (Right ()) - else do - -- Run ormolu on each file - forM_ allFiles <| \f -> do - let ormoluCmd = (Process.proc "ormolu" ["--mode", "inplace", Text.unpack f]) {Process.cwd = Just repo} - _ <- Process.readCreateProcessWithExitCode ormoluCmd "" - pure () - - -- Run hlint --refactor on each file - forM_ allFiles <| \f -> do - let hlintCmd = (Process.proc "hlint" ["--refactor", "--refactor-options=-i", Text.unpack f]) {Process.cwd = Just repo} - _ <- Process.readCreateProcessWithExitCode hlintCmd "" - pure () - - pure (Right ()) + let cmd = (Process.proc "lint" ["--fix"]) {Process.cwd = Just repo} + (code, _, _) <- Process.readCreateProcessWithExitCode cmd "" + case code of + Exit.ExitSuccess -> pure (Right ()) + Exit.ExitFailure _ -> pure (Right ()) -- lint --fix may exit non-zero but still fix things -- | Try to commit, returning error message on failure tryCommit :: FilePath -> Text -> IO (Either Text ()) -- cgit v1.2.3