aboutsummaryrefslogtreecommitdiffstats
path: root/app/History
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-05 10:11:54 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-05 14:55:59 +0100
commit23bacb83e6ea67ffdd62be630626ab50ff665abf (patch)
treefcb7691e3f8862400c00f0ca823503e5087f411e /app/History
parent1b1c3faabae530229eb675a2e70e744c2f45cbbe (diff)
feat: parse issues as markdown
Diffstat (limited to 'app/History')
-rw-r--r--app/History/PartialCommitInfo.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/app/History/PartialCommitInfo.hs b/app/History/PartialCommitInfo.hs
index 21a890a..6d93e88 100644
--- a/app/History/PartialCommitInfo.hs
+++ b/app/History/PartialCommitInfo.hs
@@ -4,7 +4,7 @@ module History.PartialCommitInfo
)
where
-import Control.Arrow (second)
+import CMark qualified as D
import Control.Exception (catch, handle)
import Data.Binary (Binary)
import Data.ByteString.Lazy.Char8 qualified as LB8
@@ -19,11 +19,13 @@ import Git qualified
import History.Cache (cached)
import History.CommitHash (CommitHash (..))
import Issue (Issue (..))
+import Issue.Parser qualified as I
import Issue.Provenance qualified as I
import Issue.Tag qualified as I
import Issue.Text qualified as I
import Parallel (parMapM)
import Process (proc, sh)
+import Render qualified as P
import System.Directory (getCurrentDirectory)
import System.FilePath ((</>))
import System.IO.Temp (withSystemTempDirectory)
@@ -85,31 +87,28 @@ fromComment cwd comment = do
commit <- I.commitFromHEAD cwd
let provenance = I.Provenance commit commit
- pure
- ( if any (\marker -> T.isPrefixOf marker title') I.issueMarkers
- then
- Just
- Issue
+ pure $
+ ( \parseResult ->
+ let (markers, title) =
+ I.stripIssueMarkers (T.pack (show (P.render parseResult.heading)))
+ in Issue
{ title = title,
- description = description,
+ description = N.nonEmpty parseResult.paragraphs,
file = comment.file,
provenance = provenance,
start = comment.start,
end = comment.end,
- tags = maybe [] I.extractTags description,
+ tags = I.extractTags parseResult.tags,
markers = markers,
rawText = rawText,
commentStyle = commentStyle,
- comments = comments,
+ comments = N.nonEmpty parseResult.comments,
closed = False
}
- else Nothing
)
+ <$> I.parse I.issueMarkers (D.commonmarkToNode [] rawText)
where
(commentStyle, rawText) = G.uncomment comment.file_type comment.text
- (title', description') = I.extractText rawText
- (markers, title) = I.stripIssueMarkers title'
- (comments, description) = maybe ([], Nothing) (second Just . I.extractComments) description'
dieOfInvalidTreeGrepperResult :: E.InvalidTreeGrepperResult -> IO a
dieOfInvalidTreeGrepperResult (E.InvalidTreeGrepperResult e) =