🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit 18e673fd0bd2e949997dc7d08ec568de7d2682f1
Parent: baeb6384dbc23c16b5ac745804da967866c63831
Author: mcol <mcol@posteo.net>
Date: 2021-09-18 23:46:15 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-18 23:46:15 +0100

Get working, but ugly, use of Git code

src/Repositories.hs Modified

@@ -37,17 +37,18 @@
 processRepo :: [Template] -> FilePath -> FilePath -> IO ()
 processRepo templates outputDirectory path = withRepository lgFactory path $ do
     liftIO $ createDirectoryIfMissing True outPath
-    ref <- lookupReference "HEAD"
+    ref <- resolveReference "HEAD"
     case ref of
-        Just commitID -> liftIO $ processRepo' templates outPath commitID
+        Just commitID -> do
+            head <- lookupCommit (Tagged commitID)
+            nodes <- lookupTree (commitTree head) >>= listTreeEntries
+            liftIO $ processRepo' templates outPath
         _ -> liftIO . print $ "gitserve: " <> (takeFileName path) <> ": Failed to resolve HEAD."
   where
     outPath = outputDirectory </> (takeFileName path)
 
-processRepo' :: [Template] -> FilePath -> RefTarget LgRepo -> IO ()
-processRepo' templates outPath commitID = do
-    --headCommit <- lookupCommit (Tagged commitID)
-    liftIO $ print "hi"
+processRepo' :: [Template] -> FilePath -> IO ()
+processRepo' templates outPath = do
     return ()
 
     --mconcat $ runGingerT (makeContextHtmlM (scopeLookup context) (putStr . unpack . htmlSource)) tpl