aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-27 13:55:04 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-27 13:55:04 +0100
commit34e3154c7ae1b002ff85cd0837c3cbf7d672d458 (patch)
tree882101d5712bddc17047f1a80a971a89aee25243 /app/Issue.hs
parentd08746a03ef75eb2c4fecb157248a762545cca1f (diff)
close separate-database-issues-and-history-issues
Diffstat (limited to 'app/Issue.hs')
-rw-r--r--app/Issue.hs67
1 files changed, 1 insertions, 66 deletions
diff --git a/app/Issue.hs b/app/Issue.hs
index 6d8746d..9d5a102 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -1,29 +1,19 @@
module Issue
( Issue (..),
Provenance (..),
- fromComment,
id,
internalTags,
- getIssues,
)
where
-import Control.Arrow qualified as W
-import Control.Exception (handle)
import Data.Binary (Binary)
import Data.List (find)
-import Data.Maybe (catMaybes)
import Data.Text qualified as T
import Data.Time.Clock (UTCTime (utctDay))
-import Exception qualified as E
import GHC.Generics (Generic)
import GHC.Records (HasField (..))
-import Issue.Provenance (Author (..), Commit (..), Provenance (..), commitFromHEAD)
+import Issue.Provenance (Author (..), Commit (..), Provenance (..))
import Issue.Tag (Tag (..))
-import Issue.Tag qualified as I
-import Issue.Text qualified as I
-import TreeGrepper.Comment (Comment (..))
-import TreeGrepper.Comment qualified as G
import TreeGrepper.Match qualified as G
import Prelude hiding (id)
@@ -65,58 +55,3 @@ toSpinalCase :: T.Text -> T.Text
toSpinalCase = T.replace " " "-" . T.filter keep . T.toLower
where
keep = (`elem` (concat [[' ', '-'], ['a' .. 'z'], ['0' .. '9']]))
-
--- TODO Refactor non-issues
---
--- This does not return an issue, as provenance is not computed over its
--- history. Maybe this should return a different type, or be internal to
--- `History`?
-fromComment :: FilePath -> Comment -> IO (Maybe Issue)
-fromComment cwd comment = do
- commit <- commitFromHEAD cwd
- let provenance = Provenance commit commit
-
- pure
- ( if any (\marker -> T.isPrefixOf marker title') issueMarkers
- then
- Just
- Issue
- { title = title,
- description = description,
- file = comment.file,
- provenance = provenance,
- start = comment.start,
- end = comment.end,
- tags = maybe [] I.extractTags description,
- markers = markers,
- rawText = rawText
- }
- else Nothing
- )
- where
- rawText = comment.text
- (title', description) = I.extractText comment.file_type rawText
- (markers, title) = stripIssueMarkers title'
-
-issueMarkers :: [T.Text]
-issueMarkers =
- [ "TODO",
- "FIXME",
- "QUESTION"
- ]
-
-stripIssueMarkers :: T.Text -> ([T.Text], T.Text)
-stripIssueMarkers text =
- case [marker | marker <- issueMarkers, T.isPrefixOf marker text] of
- (marker : _) ->
- W.first (marker :) . stripIssueMarkers $
- T.stripStart (T.drop (T.length marker) text)
- [] ->
- ([], text)
-
--- | Get all issues in the given directory and file.
-getIssues :: FilePath -> FilePath -> IO [Issue]
-getIssues cwd filename =
- handle (\(_ :: E.UnknownFileExtension) -> pure []) $
- fmap catMaybes . mapM (fromComment cwd)
- =<< G.getComments cwd filename