aboutsummaryrefslogtreecommitdiffstats
path: root/app/Git.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-13 03:47:14 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-13 04:50:01 +0100
commit2bbd2f8b692dd952903a9f1527f2779a916118ab (patch)
tree0ab292e196327f719a2e953bdaac70cf3be9abb5 /app/Git.hs
parent4426863f07901f626a537f2f0bb717b1bd1b0f6d (diff)
chore: uncache large issue fields
Diffstat (limited to 'app/Git.hs')
-rw-r--r--app/Git.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/app/Git.hs b/app/Git.hs
index be95f61..6431259 100644
--- a/app/Git.hs
+++ b/app/Git.hs
@@ -6,7 +6,8 @@ module Git
Commit (..),
Author (..),
getCommitOf,
- readTextFileOf,
+ readTextFileOfText,
+ readTextFileOfBS,
)
where
@@ -28,7 +29,6 @@ import GHC.Generics (Generic)
import Git.CommitHash
import Process (proc, sh)
import Text.Printf (printf)
-import Prelude hiding (lines)
getCommitHashes :: IO (NonEmpty T.Text)
getCommitHashes = fromMaybe (throw E.NoCommits) . N.nonEmpty . reverse . T.lines . T.decodeUtf8 . LB.toStrict <$> sh "git log --format=%H"
@@ -87,12 +87,18 @@ getCommitOf commitHash@(Commit hash) = do
}
_ -> throwIO E.NoCommits
-readTextFileOf :: CommitHash -> FilePath -> IO LT.Text
-readTextFileOf WorkingTree filePath =
+readTextFileOfText :: CommitHash -> FilePath -> IO LT.Text
+readTextFileOfText = readTextFileOf LT.readFile LT.decodeUtf8
+
+readTextFileOfBS :: CommitHash -> FilePath -> IO LB.ByteString
+readTextFileOfBS = readTextFileOf LB.readFile (\x->x)
+
+readTextFileOf :: (FilePath -> IO a) -> (LB.ByteString -> a) -> CommitHash -> FilePath -> IO a
+readTextFileOf readFile _ WorkingTree filePath =
catch
- (LT.readFile filePath)
+ (readFile filePath)
(\(_ :: IOException) -> throwIO (E.CannotReadFile filePath))
-readTextFileOf (Commit hash) filePath =
+readTextFileOf _ decode (Commit hash) filePath =
catch
- (LT.decodeUtf8 <$> sh (proc "git show %:%" hash filePath))
+ (decode <$> sh (proc "git show %:%" hash filePath))
(\(_ :: E.ProcessException) -> throwIO (E.CannotReadFile (printf "%s:%s" hash filePath)))