Commit e1bd7034724d08b208da2059208f37a5b2005785 Parent: 759165bd351f359e5df08979785dec4beddc8222 Author: mcol <mcol@posteo.net> Date: 2021-09-24 23:42:47 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-09-24 23:42:47 +0100 Package tree data into type
src/Repositories.hs Modified
@@ -87,7 +87,7 @@ -> FilePath -> Text -> [Commit LgRepo] - -> [(TreeFilePath, TreeEntry r)] + -> [TreeFile] -> HashMap.HashMap Text (GVal (Run SourcePos IO Html)) package config name description commits tree = HashMap.fromList [ ("host", toGVal $ host config) @@ -106,8 +106,15 @@ loadCommit (CommitObjOid oid) = Just $ lookupCommit oid loadCommit _ = Nothing -getTree :: CommitOid LgRepo -> ReaderT LgRepo IO [(TreeFilePath, TreeEntry LgRepo)] -getTree commitID = lookupCommit commitID >>= lookupTree . commitTree >>= listTreeEntries +data TreeFile = TreeFile + { treeFilePath :: TreeFilePath + , treeEntry :: TreeEntry LgRepo + } + +getTree :: CommitOid LgRepo -> ReaderT LgRepo IO [TreeFile] +getTree commitID = do + entries <- listTreeEntries =<< lookupTree . commitTree =<< lookupCommit commitID + return $ uncurry TreeFile <$> entries getDescription :: FilePath -> IO Text getDescription path = fromRight "" <$> tryIOError (pack <$> readFile path)