aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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