diff options
Diffstat (limited to 'app/History/Scramble.hs')
-rw-r--r-- | app/History/Scramble.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/History/Scramble.hs b/app/History/Scramble.hs index 39a1ac7..093db98 100644 --- a/app/History/Scramble.hs +++ b/app/History/Scramble.hs @@ -1,5 +1,6 @@ module History.Scramble ( Scramble (..), + getScramble, getIssuesOfFile, fromComment, ) @@ -34,6 +35,30 @@ data Scramble = Scramble } deriving (Show, Binary, Generic) +getScramble :: Backend.CommitHash -> IO Scramble +getScramble commitHash@Backend.WorkingTree = do + filesChanged <- Backend.getFilesOf commitHash + issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged + pure $ + Scramble + { issues = + M.unions + [ M.singleton issue.id issue | issue <- issues + ], + .. + } +getScramble commitHash@(Backend.Commit _) = do + filesChanged <- Backend.getChangedFilesOf commitHash + issues <- concat <$> mapM (getIssuesOfFile commitHash) filesChanged + pure $ + Scramble + { issues = + M.unions + [ M.singleton issue.id issue | issue <- issues + ], + .. + } + -- | Get all issues in the given directory and file. getIssuesOfFile :: Backend.CommitHash -> FilePath -> IO [I.Issue] getIssuesOfFile commitHash filename = |