aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs33
1 files changed, 3 insertions, 30 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 5e48568..d75ef9c 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -74,13 +74,11 @@
module Main where
-import Control.Exception (catch, handle)
-import Data.ByteString.Lazy.Char8 qualified as L8
-import Data.List (find, intercalate)
+import Data.List (find)
import Data.Maybe (catMaybes, fromMaybe)
import Data.String qualified as String
import Data.Text qualified as T
-import History (InvalidTreeGrepperResult (..), UnknownFileExtension (..), getIssues)
+import History (listIssues)
import Issue (Issue (..))
import Issue qualified as I
import Issue.Filter (Filter)
@@ -90,7 +88,7 @@ import Options.Applicative ((<**>))
import Options.Applicative qualified as O
import Prettyprinter qualified as P
import Prettyprinter.Render.Terminal qualified as P
-import Process (quote, sh, sh_)
+import Process (sh_)
import System.Exit (ExitCode (ExitFailure), exitWith)
import System.Process.Typed qualified as P
import Text.Printf
@@ -246,28 +244,3 @@ putDoc doc = do
P.putDoc . (if isTty then (\x -> x) else P.unAnnotate) $ doc
foreign import ccall "unistd.h isatty" c_isatty :: Int -> IO Int
-
-listIssues :: [Filter] -> [FilePath] -> IO [Issue]
-listIssues filters files =
- filter (I.applyFilter filters) . concat
- <$> catch
- ( mapM (handle forgetGetIssuesExceptions . getIssues)
- =<< getFiles files
- )
- (\(InvalidTreeGrepperResult e) -> die e)
- where
- forgetGetIssuesExceptions :: UnknownFileExtension -> IO [a]
- forgetGetIssuesExceptions _ = pure []
-
-getFiles :: [String] -> IO [FilePath]
-getFiles files =
- lines . L8.unpack
- <$> sh
- ( String.fromString
- ( (printf "git ls-files --cached --exclude-standard --other%s")
- ( case files of
- [] -> ""
- _ -> " -- " ++ intercalate " " (map quote files)
- )
- )
- )