Commit be1eb29554197bd3f25deea0a839007134a89e0a Parent: 9f6bc429c2342d61fb7c1ca5341cdc972ff95a77 Author: mcol <mcol@posteo.net> Date: 2021-09-22 00:09:00 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-09-22 00:09:00 +0100 Split ReaderT monads out into sub functions
src/Repositories.hs Modified
@@ -50,11 +50,10 @@ Nothing -> liftIO . print $ "gitserve: " <> name <> ": Failed to resolve HEAD." Just commitID -> do description <- liftIO $ getDescription $ outPath </> "description" - headc <- lookupCommit $ Tagged commitID - obj <- runConduit $ sourceObjects Nothing (Tagged commitID) False .| sinkList + obj <- getCommits $ Tagged commitID --a <- loadObject . head $ obj --liftIO . print . loadObject <$> obj - nodes <- lookupTree (commitTree headc) >>= listTreeEntries + tree <- getTree $ Tagged commitID return () where name = takeFileName path @@ -62,6 +61,14 @@ --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 + +getTree :: CommitOid LgRepo -> ReaderT LgRepo IO [(TreeFilePath, TreeEntry LgRepo)] +getTree commitID = do + headc <- lookupCommit commitID + lookupTree (commitTree headc) >>= listTreeEntries + getDescription :: FilePath -> IO String getDescription path = tryIOError (readFile path) >>= \e -> case e of