aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/History.hs44
1 files changed, 24 insertions, 20 deletions
diff --git a/app/History.hs b/app/History.hs
index 09d66e1..252380d 100644
--- a/app/History.hs
+++ b/app/History.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
-module History (getIssues, InvalidTreeGrepperResult (..), UnknownFileExtension (..), listIssues) where
+module History (getIssues, listIssues) where
import Control.Exception (Exception, catch, handle, throw)
import Data.Aeson (eitherDecode)
@@ -28,20 +28,6 @@ import TreeGrepper.Result qualified as G
import Prelude hiding (id, lines)
import Prelude qualified as Prelude
-data UnknownFileExtension = UnknownFileExtension
- { extension :: String
- }
- deriving (Show)
-
-instance Exception UnknownFileExtension
-
-data InvalidTreeGrepperResult = InvalidTreeGrepperResult
- { error :: String
- }
- deriving (Show)
-
-instance Exception InvalidTreeGrepperResult
-
listIssues :: [Filter] -> [FilePath] -> IO [Issue]
listIssues filters paths = do
commits <- getCommits
@@ -77,7 +63,7 @@ listIssuesCurrent :: [FilePath] -> IO [Issue]
listIssuesCurrent paths = do
worktree <- getCurrentDirectory
files <- getFiles worktree paths
- concat <$> (catch (getIssuesPar worktree files) (\(InvalidTreeGrepperResult e) -> die e))
+ concat <$> (catch (getIssuesPar worktree files) dieOfInvalidTreeGrepperResult)
listIssuesOf :: Text -> IO [Issue]
listIssuesOf commit = do
@@ -87,10 +73,7 @@ listIssuesOf commit = do
sh_ (fromString (printf "git worktree add --detach %s %s" (quote worktree) (quote (unpack commit))))
pure worktree
files <- getFilesChanged worktree
- concat <$> catch (getIssuesPar worktree files) (\(InvalidTreeGrepperResult e) -> die e)
-
-forgetGetIssuesExceptions :: UnknownFileExtension -> IO [a]
-forgetGetIssuesExceptions _ = pure []
+ concat <$> catch (getIssuesPar worktree files) (dieOfInvalidTreeGrepperResult)
getFiles :: FilePath -> [String] -> IO [FilePath]
getFiles cwd paths =
@@ -118,6 +101,27 @@ getIssuesPar :: FilePath -> [FilePath] -> IO [[Issue]]
getIssuesPar worktree =
parMapM (handle forgetGetIssuesExceptions . getIssues worktree)
+data UnknownFileExtension = UnknownFileExtension
+ { extension :: String
+ }
+ deriving (Show)
+
+instance Exception UnknownFileExtension
+
+forgetGetIssuesExceptions :: UnknownFileExtension -> IO [a]
+forgetGetIssuesExceptions _ = pure []
+
+data InvalidTreeGrepperResult = InvalidTreeGrepperResult
+ { error :: String
+ }
+ deriving (Show)
+
+instance Exception InvalidTreeGrepperResult
+
+dieOfInvalidTreeGrepperResult :: InvalidTreeGrepperResult -> IO a
+dieOfInvalidTreeGrepperResult (InvalidTreeGrepperResult e) =
+ die e
+
getIssues :: FilePath -> FilePath -> IO [Issue]
getIssues cwd filename = do
let extension = takeExtension filename