{-# LANGUAGE OverloadedStrings #-}

module Lib
    ( someFunc
    ) where

import Control.Monad.IO.Class (liftIO)
import Git.Blob (blobCreateFrombuffer)
import Git.Commit (commitCreate, withCommit)
import Git.Libgit2 (withLibgit2)
import Git.Reference (referenceNameToId, refHead)
import Git.Repository (withNewRepository, repositoryHeadUnborn)
import Git.Signature (Signature(Signature))
import Git.Tree (Update(UpdateUpsert), treeCreateUpdated, withTree)
import Git.Types (filemodeBlob)

someFunc :: IO ()
someFunc = withLibgit2 $ withNewRepository "/home/sigi/wiki2.git" $ do
    blob <- blobCreateFrombuffer "Hallo, Sigi!"
    treeOid <- treeCreateUpdated [UpdateUpsert blob "README"]
    let sig = Signature "Siegfried Weber" "mail@siegfriedweber.net"
    withTree treeOid $ \tree ->
        commitCreate refHead sig sig "my first commit" tree []
    headUnborn <- repositoryHeadUnborn
    head <- referenceNameToId refHead
    withCommit head $
        liftIO $ putStrLn "someFunc"

