aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/CommitInfo.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-30 03:49:39 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-30 03:49:41 +0100
commit650d139254a0e17be0b1011f2fda6ea67f903e71 (patch)
treeebfcd8606da922c536cb6414cfa816d2aa65c17f /app/History/CommitInfo.hs
parentff5535f0a55201c6883c48c3892c9ef357904356 (diff)
feat: support closed issues
Closed issues can be shown, but listing closed issues requires passing `--closed`.
Diffstat (limited to 'app/History/CommitInfo.hs')
-rw-r--r--app/History/CommitInfo.hs56
1 files changed, 27 insertions, 29 deletions
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.