diff options
author | Fabian Kirchner <fabian.kirchner@hereon.de> | 2023-11-29 13:46:43 +0100 |
---|---|---|
committer | Fabian Kirchner <fabian.kirchner@hereon.de> | 2023-11-29 13:46:43 +0100 |
commit | cffebbf54cba9b99db0629a7179a18ff8168159f (patch) | |
tree | 25a81ed59d1ee3cb7f6549580d732f35e6b4d56b /app/History/CommitInfo.hs | |
parent | e0ef5340859ef88a7aeddf54a7b8c50a2488fc11 (diff) |
fix: compute issueEvents correctly
Diffstat (limited to 'app/History/CommitInfo.hs')
-rw-r--r-- | app/History/CommitInfo.hs | 15 |
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 |