aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-07 22:00:43 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-07 22:01:55 +0100
commit8ee9303043fafe916fe59e43895a1753882d5139 (patch)
tree6034ffb60da73495d8b8b5e8333bbf135f1a91ff /app
parent8d1646b6545ceeda6fc7a57356fd6e72e66d39b9 (diff)
fix `getRootDir` returning wrong path
Check for `../anissue\n` having been created by invocations prior to this fix.
Diffstat (limited to 'app')
-rw-r--r--app/Git.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/Git.hs b/app/Git.hs
index c72edea..af02b70 100644
--- a/app/Git.hs
+++ b/app/Git.hs
@@ -7,6 +7,7 @@ where
import Control.Exception (finally)
import Data.ByteString.Lazy.Char8 qualified as LB8
+import Data.Maybe (fromMaybe)
import Data.Text qualified as T
import Data.Text.Encoding qualified as T
import Process (proc, sh, sh_)
@@ -25,4 +26,6 @@ getCommitHashes :: IO [T.Text]
getCommitHashes = T.lines . T.decodeUtf8 . LB8.toStrict <$> sh "git log --format=%H"
getRootDir :: IO FilePath
-getRootDir = T.unpack . T.decodeUtf8 . LB8.toStrict <$> sh (proc "git rev-parse --show-toplevel")
+getRootDir = T.unpack . stripTrailingNL . T.decodeUtf8 . LB8.toStrict <$> sh (proc "git rev-parse --show-toplevel")
+ where
+ stripTrailingNL s = fromMaybe s $ T.stripSuffix "\n" s