aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Issue.hs')
-rw-r--r--app/Issue.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/Issue.hs b/app/Issue.hs
index a4e2d73..451b897 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -17,7 +17,7 @@ import Data.Text (Text)
import Data.Text qualified as T
import Exception qualified as E
import GHC.Generics (Generic)
-import Issue.Provenance (Provenance (..), provenanceFromHEAD)
+import Issue.Provenance (Provenance (..), commitFromHEAD)
import Issue.Tag (Tag (..))
import Issue.Tag qualified as I
import Issue.Text qualified as I
@@ -35,6 +35,9 @@ data Issue = Issue
{ title :: Text,
description :: Maybe Text,
file :: String,
+ -- TODO Make provenance obligatory
+ --
+ -- I cannot think of instances where an issue exists without a provenance..
provenance :: Maybe Provenance,
start :: G.Position,
end :: G.Position,
@@ -48,9 +51,15 @@ id issue =
(\(Tag _ v) -> T.unpack <$> v)
=<< find (\(Tag k _) -> k == "id") (issue.tags ++ issue.internalTags)
+-- 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`? Also, `internalTags` suffer.
fromMatch :: FilePath -> G.Result -> G.Match -> IO (Maybe Issue)
fromMatch cwd result match = do
- provenance <- provenanceFromHEAD cwd
+ commit <- commitFromHEAD cwd
+ let provenance = Provenance commit commit
pure
( if any (\marker -> T.isPrefixOf marker title') issueMarkers
@@ -60,11 +69,11 @@ fromMatch cwd result match = do
{ title = title,
description = description,
file = result.file,
- provenance = provenance,
+ provenance = Just provenance,
start = match.start,
end = match.end,
tags = maybe [] I.extractTags description,
- internalTags = I.internalTags title provenance
+ internalTags = I.internalTags title (Just provenance)
}
else Nothing
)