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 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'app/History/CommitInfo.hs') 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. -- cgit v1.2.3