{-# LANGUAGE RankNTypes #-}
module Git.Class
( GitImpl (..)
, GitObject (..)
, HistoryItem (..)
) where
import ClassyPrelude hiding (hash, stderr, stdin, stdout)
import Conduit (ConduitT, MonadResource)
import System.OsPath (OsPath)
-- TODO: figure out exceptions for operations, because a lot of things can fail here
data GitImpl = GitImpl
{ createRepo :: OsPath -> IO ()
, renameRepo :: OsPath -> OsPath -> IO ()
, getBranches :: OsPath -> IO [Text]
, getObject :: OsPath -> OsPath -> IO GitObject
, getLastCommits :: OsPath -> IO [HistoryItem]
, advertiseRefsUpload
:: forall m
. MonadResource m
=> OsPath
-> Maybe ByteString
-> ConduitT () ByteString m ()
, advertiseRefsReceive
:: forall m
. MonadResource m
=> OsPath
-> Maybe ByteString
-> ConduitT () ByteString m ()
, uploadPack
:: forall m
. MonadResource m
=> OsPath
-> Maybe ByteString
-> ConduitT ByteString ByteString m ()
, receivePack
:: forall m
. MonadResource m
=> OsPath
-> Maybe ByteString
-> ConduitT ByteString ByteString m ()
}
data GitObject
= Commit ByteString
| Tree [ByteString]
| -- | TODO parse
Blob ByteString
| -- | TODO parse
Tag ByteString
deriving (Eq, Show)
data HistoryItem = HistoryItem
{ commitHash :: !Text
, commitAuthor :: !Text
, parentRef :: !Text
-- ^ Human readable name. Can be branch or tag name
, createDate :: !Day
, shortCommitMessage :: !Text
, isTag :: !Bool
}
deriving (Eq, Show)