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

Commit fdc7043afc2eb29bf0c7ef43779a852e9c39f739
Parent: d0ffe9b7561ed14c2f8148b2c9c5c5e08d0ca48c
Author: mcol <mcol@posteo.net>
Date: 2021-09-17 00:48:43 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-17 00:48:43 +0100

Add some git dependencies and basic function to get commit message

stack.yaml.lock Modified

@@ -3,7 +3,21 @@
 # For more information, please see the documentation at:
 #   https://docs.haskellstack.org/en/stable/lock_files
 
-packages: []
+packages:
+- completed:
+    hackage: gitlib-3.1.3@sha256:7e8f940b380f6155be3bf20be9f363c3bfd3285bd26e0368f406a1c431994598,2935
+    pantry-tree:
+      size: 982
+      sha256: dd61ec3d4a2446b20609823c013abea02874c9ca8887f23e7ac05af4bbe5a4b4
+  original:
+    hackage: gitlib-3.1.3@sha256:7e8f940b380f6155be3bf20be9f363c3bfd3285bd26e0368f406a1c431994598,2935
+- completed:
+    hackage: gitlib-libgit2-3.1.2.1@sha256:36bc92f117158440ca69e32051aabdf9df75be8a3fb5f45dff8828898e615a0a,2354
+    pantry-tree:
+      size: 516
+      sha256: 47695cdeb7c1fb95a5c4bfd21bf46014554ccdd1e5059d5558a0348042044f39
+  original:
+    hackage: gitlib-libgit2-3.1.2.1@sha256:36bc92f117158440ca69e32051aabdf9df75be8a3fb5f45dff8828898e615a0a,2354
 snapshots:
 - completed:
     size: 587546

stack.yaml Modified

@@ -3,3 +3,7 @@
 
 packages:
 - .
+
+extra-deps:
+- gitlib-3.1.3@sha256:7e8f940b380f6155be3bf20be9f363c3bfd3285bd26e0368f406a1c431994598,2935
+- gitlib-libgit2-3.1.2.1@sha256:36bc92f117158440ca69e32051aabdf9df75be8a3fb5f45dff8828898e615a0a,2354

src/Repositories.hs Added

@@ -0,0 +1,18 @@
+{-# Language OverloadedStrings #-}  -- Needed for repository paths.
+
+module Repositories (
+    getLog
+) where
+
+import Control.Monad.IO.Class (liftIO)
+import Data.Tagged
+import Git
+import Git.Libgit2 (lgFactory)
+
+getLog path = withRepository lgFactory path $ do
+    maybeObjID <- resolveReference "HEAD"
+    case maybeObjID of
+        Just commitID -> do
+            headCommit <- lookupCommit (Tagged commitID)
+            liftIO $ print $ commitLog headCommit
+        _ -> liftIO (print "Couldn't resolve HEAD")

src/Main.hs Modified

@@ -1,5 +1,7 @@
 module Main where
 
+import Repositories
+
 main :: IO ()
 main = do
-  putStrLn "hello world"
+  getLog "."

gitserve.cabal Modified

@@ -16,5 +16,9 @@
 executable gitserve
   hs-source-dirs:      src
   main-is:             Main.hs
+  other-modules:       Repositories
   default-language:    Haskell2010
   build-depends:       base >= 4.7 && < 5
+                     , gitlib
+                     , gitlib-libgit2
+                     , tagged