From 650d139254a0e17be0b1011f2fda6ea67f903e71 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 30 Nov 2023 03:49:39 +0100 Subject: feat: support closed issues Closed issues can be shown, but listing closed issues requires passing `--closed`. --- app/History/CommitInfo.hs | 56 +++++++++++++++++++--------------------- app/History/PartialCommitInfo.hs | 3 ++- 2 files changed, 29 insertions(+), 30 deletions(-) (limited to 'app/History') diff --git a/app/History/CommitInfo.hs b/app/History/CommitInfo.hs index e260ce6..8e9f3b9 100644 --- a/app/History/CommitInfo.hs +++ b/app/History/CommitInfo.hs @@ -9,14 +9,14 @@ where import Data.Binary (Binary) import Data.Function (on) import Data.List (deleteFirstsBy, find) -import Data.Maybe (catMaybes, isJust) +import Data.Maybe (isJust) import GHC.Generics (Generic) import History.CommitHash (CommitHash) import History.IssueEvent (IssueEvent (..)) import History.PartialCommitInfo (PartialCommitInfo (..)) -import Issue (Issue (..), id) +import Issue (Issue (..)) import Issue.Provenance qualified as I -import Prelude hiding (id) +import Prelude -- TODO Change `CommitInfo` -> `CommitIssuesAll` data CommitInfo = CommitInfo @@ -38,35 +38,33 @@ fromPartialCommitInfos (partialCommitInfo : partialCommitInfos) = propagate oldInfo newInfo@(PartialCommitInfo {..}) = CommitInfo { issues = - catMaybes $ - mergeListsBy - eq - ( \old new -> - Just - new - { provenance = - I.Provenance - { first = old.provenance.first, - last = - if ((/=) `on` (.rawText)) old new - then new.provenance.last - else old.provenance.last - } - } - ) - ( \old -> - if elemBy eq old newInfo.issues - || not (old.file `elem` newInfo.filesChanged) - then Just old - else Nothing - ) - (\new -> Just new) - oldInfo.issues - newInfo.issues, + mergeListsBy + eq + ( \old new -> + new + { provenance = + I.Provenance + { first = old.provenance.first, + last = + if ((/=) `on` (.rawText)) old new + then new.provenance.last + else old.provenance.last + } + } + ) + ( \old -> + if elemBy eq old newInfo.issues + || not (old.file `elem` newInfo.filesChanged) + then old + else old {closed = True} + ) + id + oldInfo.issues + newInfo.issues, .. } - eq = (==) `on` id + eq = (==) `on` (.id) -- | We assume that [CommitInfo] is sorted starting with the oldest -- commits. diff --git a/app/History/PartialCommitInfo.hs b/app/History/PartialCommitInfo.hs index f973938..48b631e 100644 --- a/app/History/PartialCommitInfo.hs +++ b/app/History/PartialCommitInfo.hs @@ -102,7 +102,8 @@ fromComment cwd comment = do markers = markers, rawText = rawText, commentStyle = commentStyle, - comments = comments + comments = comments, + closed = False } else Nothing ) -- cgit v1.2.3