aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-13 20:45:00 +0200
committerLibravatar Fabian Kirchner <kirchner@posteo.de>2023-10-13 20:45:00 +0200
commit09d5a5941a1feb23aece4d5311092c1a23d4ae11 (patch)
tree1942bba783535031e4d07b1828f434e78ce4e1d8
parentc0ba5044d9f36ad91d0ef8a11a5cb5adabcea33f (diff)
also support FIXME and QUESTION as markers
-rw-r--r--app/Issue.hs23
-rw-r--r--app/Main.hs5
2 files changed, 16 insertions, 12 deletions
diff --git a/app/Issue.hs b/app/Issue.hs
index a222d0a..ab47ba5 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -5,7 +5,7 @@
module Issue (Issue (..), fromMatch, id) where
-import Data.List (find)
+import Data.List (find, foldl')
import Data.Text (Text)
import Data.Text qualified as T
import Issue.Tag (Tag (..))
@@ -37,7 +37,7 @@ id issue =
fromMatch :: G.Result -> G.Match -> Maybe Issue
fromMatch result match =
- if T.isPrefixOf marker title'
+ if any (\marker -> T.isPrefixOf marker title') issueMarkers
then
Just
Issue
@@ -52,10 +52,19 @@ fromMatch result match =
else Nothing
where
(title', description) = I.extractText result.file_type match.text
- title = stripMarker title'
+ title = stripIssueMarkers title'
-marker :: Text
-marker = "TODO"
+issueMarkers :: [Text]
+issueMarkers =
+ [ "TODO",
+ "FIXME",
+ "QUESTION"
+ ]
-stripMarker :: Text -> Text
-stripMarker text = maybe text T.stripStart (T.stripPrefix marker text)
+stripIssueMarkers :: Text -> Text
+stripIssueMarkers text =
+ foldl' (stripIssueMarker) text issueMarkers
+
+stripIssueMarker :: Text -> Text -> Text
+stripIssueMarker text marker =
+ maybe text T.stripStart (T.stripPrefix marker text)
diff --git a/app/Main.hs b/app/Main.hs
index 0faff19..9e25025 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -70,11 +70,6 @@
-- # @original-issue more information on the issue
-- ```
--- TODO Add support for other keywords
---
--- Additionally to TODO, also FIXME should start an issue. There might
--- be more interesting keywords.
-
module Main where
import Control.Exception (Exception, catch, handle, throw, throwIO)