From 8ee9303043fafe916fe59e43895a1753882d5139 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 7 Nov 2023 22:00:43 +0100 Subject: fix `getRootDir` returning wrong path Check for `../anissue\n` having been created by invocations prior to this fix. --- app/Git.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3