diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-10-20 09:55:13 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-07 09:50:52 +0100 |
commit | eafbd88429a80f058efaa4efd28fbfb8271065c3 (patch) | |
tree | 35ae08955e34014fa6666bab26807a42fbbbbcee /app/Issue.hs | |
parent | ea1236f2cf6d3ef4b739b2ca28f47a3bbed42295 (diff) |
record both creation and update in provenance
Diffstat (limited to 'app/Issue.hs')
-rw-r--r-- | app/Issue.hs | 17 |
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 ) |