diff options
author | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 00:06:38 +0200 |
---|---|---|
committer | Fabian Kirchner <kirchner@posteo.de> | 2023-10-14 00:06:38 +0200 |
commit | 4b46f5fd6cb80305ce4f03b992bba68dd07d112e (patch) | |
tree | b8ead3d840dca61a5c07d69098df15d758804d31 /app/Main.hs | |
parent | 29d809eb49820e89637f1455a5e5687fe9155143 (diff) |
extract listIssues to History and make commit configurable
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 33 |
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) - ) - ) - ) |