diff options
Diffstat (limited to 'app/History.hs')
-rw-r--r-- | app/History.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/History.hs b/app/History.hs index 31651bd..0e498b7 100644 --- a/app/History.hs +++ b/app/History.hs @@ -12,12 +12,14 @@ import Control.Arrow (first) import Control.Exception (catch, handle, try) import Data.Binary (Binary) import Data.ByteString.Lazy qualified as LB +import Data.Digest.Pure.SHA qualified as S import Data.Function (on) -import Data.List.NonEmpty qualified as N import Data.Map qualified as M import Data.Maybe (catMaybes) import Data.Text qualified as T import Data.Text.Encoding qualified as T +import Data.Text.Lazy qualified as LT +import Data.Text.Lazy.Encoding qualified as LT import Die (die) import Exception qualified as E import GHC.Generics (Generic) @@ -123,17 +125,19 @@ fromComment commitHash comment = do let (markers, title) = I.stripIssueMarkers (T.pack (show (P.render parseResult.heading))) in I.Issue - { title = title, - description = N.nonEmpty parseResult.paragraphs, + { commitHash = commitHash, + language = comment.language, + rawTextHash = S.sha1 (LT.encodeUtf8 (LT.fromStrict rawText)), + title = title, file = comment.filePath, provenance = provenance, + startByte = comment.startByte, + endByte = comment.endByte, startPoint = comment.startPoint, endPoint = comment.endPoint, tags = I.extractTags parseResult.tags, markers = markers, - rawText = rawText, commentStyle = commentStyle, - comments = N.nonEmpty parseResult.comments, closed = False } ) @@ -159,7 +163,7 @@ propagateIssues oldIssues scramble = I.Provenance { first = old.provenance.first, last = - if ((/=) `on` (.rawText)) old new + if ((/=) `on` (.rawTextHash)) old new then new.provenance.last else old.provenance.last }, @@ -190,7 +194,7 @@ newIssueEvents oldIssues' commitHash issues' = ], [ IssueChanged commitHash oldIssue newIssue | (newIssue, oldIssue) <- M.elems (M.intersectionWith (,) issues oldIssues), - newIssue `neq` oldIssue + ((/=) `on` (.rawTextHash)) newIssue oldIssue ], [ IssueDeleted commitHash issue {I.closed = True} | issue <- M.elems (oldIssues `M.difference` issues) @@ -200,8 +204,6 @@ newIssueEvents oldIssues' commitHash issues' = issues = M.filter (not . (.closed)) issues' oldIssues = M.filter (not . (.closed)) oldIssues' - neq = (/=) `on` (.rawText) - unsafeAssume :: CommitHash -> Scramble -> History unsafeAssume commitHash scramble = History |