From eafbd88429a80f058efaa4efd28fbfb8271065c3 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 20 Oct 2023 09:55:13 +0200 Subject: record both creation and update in provenance --- app/Issue.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/Issue.hs') 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 ) -- cgit v1.2.3