Commit 8e097ae036350cbbfcb03249c5744ec3ccee5e31 Parent: f84ded6b6f7b253c7656e9764b6ec53b145dd571 Author: mcol <mcol@posteo.net> Date: 2021-09-22 11:22:13 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-09-22 11:45:30 +0100 Move more commit code into getCommits
src/Repositories.hs Modified
@@ -5,6 +5,7 @@ ) where import Conduit (runConduit, (.|), sinkList) +import Control.Monad ((<=<)) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Reader (ReaderT) import Data.Foldable (foldMap) @@ -50,10 +51,9 @@ Nothing -> liftIO . print $ "gitserve: " <> name <> ": Failed to resolve HEAD." Just commitID -> do description <- liftIO $ getDescription $ outPath </> "description" - obj <- getCommits $ Tagged commitID - --a <- loadObject . head $ obj - --liftIO . print . loadObject <$> obj - tree <- getTree $ Tagged commitID + let head = Tagged commitID + commits <- getCommits head + tree <- getTree head return () where name = takeFileName path @@ -61,8 +61,12 @@ --mconcat $ runGingerT (makeContextHtmlM (scopeLookup context) (putStr . unpack . htmlSource)) tpl -getCommits :: CommitOid LgRepo -> ReaderT LgRepo IO [ObjectOid LgRepo] -getCommits commitID = runConduit $ sourceObjects Nothing commitID False .| sinkList +getCommits :: CommitOid LgRepo -> ReaderT LgRepo IO [Commit LgRepo] +getCommits commitID = sequence . fmap loadCommit <=< + runConduit $ sourceObjects Nothing commitID False .| sinkList + +loadCommit :: ObjectOid LgRepo -> ReaderT LgRepo IO (Commit LgRepo) +loadCommit (CommitObjOid oid) = lookupCommit oid getTree :: CommitOid LgRepo -> ReaderT LgRepo IO [(TreeFilePath, TreeEntry LgRepo)] getTree commitID = do