diff options
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/Worker.hs | 34 |
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 ()) |
