aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar Fabian Kirchner <fabian.kirchner@hereon.de>2023-11-29 13:46:43 +0100
committerLibravatar Fabian Kirchner <fabian.kirchner@hereon.de>2023-11-29 13:46:43 +0100
commitcffebbf54cba9b99db0629a7179a18ff8168159f (patch)
tree25a81ed59d1ee3cb7f6549580d732f35e6b4d56b /app
parente0ef5340859ef88a7aeddf54a7b8c50a2488fc11 (diff)
fix: compute issueEvents correctly
Diffstat (limited to 'app')
-rw-r--r--app/History/CommitInfo.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/History/CommitInfo.hs b/app/History/CommitInfo.hs
index bea0cd3..e260ce6 100644
--- a/app/History/CommitInfo.hs
+++ b/app/History/CommitInfo.hs
@@ -68,13 +68,15 @@ fromPartialCommitInfos (partialCommitInfo : partialCommitInfos) =
eq = (==) `on` id
+-- | We assume that [CommitInfo] is sorted starting with the oldest
+-- commits.
issueEvents :: [CommitInfo] -> [(CommitHash, [IssueEvent])]
-issueEvents xs = zip (map (.hash) xs') (zipWith diffCommitInfos xs xs')
+issueEvents xs = zip (map (.hash) xs) (zipWith diffCommitInfos predecessors xs)
where
- xs' = tail xs
+ predecessors = Nothing : map Just xs
-diffCommitInfos :: CommitInfo -> CommitInfo -> [IssueEvent]
-diffCommitInfos oldInfo newInfo =
+diffCommitInfos :: Maybe CommitInfo -> CommitInfo -> [IssueEvent]
+diffCommitInfos maybeOldInfo newInfo =
concat
[ [IssueCreated newHash issue | issue <- deleteFirstsBy eq newIssues oldIssues],
[ IssueChanged newHash (last issues)
@@ -86,7 +88,10 @@ diffCommitInfos oldInfo newInfo =
where
newHash = newInfo.hash
newIssues = newInfo.issues
- oldIssues = oldInfo.issues
+ oldIssues =
+ case maybeOldInfo of
+ Nothing -> []
+ Just oldInfo -> oldInfo.issues
eq = (==) `on` id