aboutsummaryrefslogtreecommitdiffstats
path: root/app/Git.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Git.hs')
-rw-r--r--app/Git.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/app/Git.hs b/app/Git.hs
index e195d1b..65ecf89 100644
--- a/app/Git.hs
+++ b/app/Git.hs
@@ -22,7 +22,6 @@ import Data.List.NonEmpty (NonEmpty)
import Data.List.NonEmpty qualified as N
import Data.Maybe (fromMaybe)
import Data.Text qualified as T
-import Data.Text.Encoding qualified as T
import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.Encoding qualified as LT
import Data.Text.Lazy.IO qualified as LT
@@ -35,19 +34,21 @@ import Process (proc, sh, sh_)
import Text.Printf (printf)
getCommitHashes :: IO (NonEmpty T.Text)
-getCommitHashes = fromMaybe (throw E.NoCommits) . N.nonEmpty . reverse . T.lines . T.decodeUtf8 . LB.toStrict <$> sh "git log --format=%H"
+getCommitHashes = fromMaybe (throw E.NoCommits) . N.nonEmpty . reverse . T.lines <$> sh "git log --format=%H"
getRootDir :: IO FilePath
-getRootDir = T.unpack . stripTrailingNL . T.decodeUtf8 . LB.toStrict <$> sh (proc "git rev-parse --show-toplevel")
+getRootDir =
+ T.unpack . stripTrailingNL
+ <$> sh (proc "git rev-parse --show-toplevel")
where
stripTrailingNL s = fromMaybe s $ T.stripSuffix "\n" s
getChangedFilesOf :: CommitHash -> IO [FilePath]
-getChangedFilesOf WorkingTree = do
- map T.unpack . T.lines . T.decodeUtf8 . LB.toStrict
+getChangedFilesOf WorkingTree =
+ map T.unpack . T.lines
<$> sh "git ls-files --modified"
-getChangedFilesOf (Commit hash) = do
- map T.unpack . T.lines . T.decodeUtf8 . LB.toStrict
+getChangedFilesOf (Commit hash) =
+ map T.unpack . T.lines
<$> sh (proc "git show -p --name-only --format= %" hash)
data Commit = Commit'
@@ -66,15 +67,15 @@ data Author = Author
getCommitOf :: CommitHash -> IO Commit
getCommitOf commitHash@WorkingTree = do
date <- getCurrentTime
- authorName <- T.decodeUtf8 . LB.toStrict <$> sh "git config user.name"
- authorEmail <- T.decodeUtf8 . LB.toStrict <$> sh "git config user.email"
+ authorName <- sh "git config user.name"
+ authorEmail <- sh "git config user.email"
pure
Commit'
{ author = Author authorName authorEmail,
..
}
getCommitOf commitHash@(Commit hash) = do
- ( T.splitOn "\NUL" . head . T.lines . T.decodeUtf8 . LB.toStrict
+ ( T.splitOn "\NUL" . head . T.lines
<$> sh
( proc
"git show --quiet --format=%%ai%%x00%%ae%%x00%%an %"