summaryrefslogtreecommitdiff
path: root/Omni/Agent/Worker.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-26 06:04:51 -0500
committerBen Sima <ben@bensima.com>2025-11-26 06:04:51 -0500
commit3af8739ed1eefdb24d1eb42837b2dae13c2b411b (patch)
tree2c3ef9d1dc5fe34090c87ef4e27cf736fbcb8659 /Omni/Agent/Worker.hs
parent240a055709657f04b838d18325a647644fea90df (diff)
Simplify worker to use lint --fix
Task-Id: t-1o2g8gugkr1
Diffstat (limited to 'Omni/Agent/Worker.hs')
-rw-r--r--Omni/Agent/Worker.hs34
1 files changed, 6 insertions, 28 deletions
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 ())