add catCommit, with commit object parser
This commit is contained in:
parent
be2e9427ad
commit
1f91d1d0b7
3 changed files with 77 additions and 1 deletions
16
Git/Env.hs
16
Git/Env.hs
|
@ -10,6 +10,7 @@
|
|||
module Git.Env where
|
||||
|
||||
import Git
|
||||
import Git.Types
|
||||
import Utility.Env
|
||||
|
||||
{- Adjusts the gitEnv of a Repo. Copies the system environment if the repo
|
||||
|
@ -36,3 +37,18 @@ adjustGitEnv g adj = do
|
|||
|
||||
addGitEnv :: Repo -> String -> String -> IO Repo
|
||||
addGitEnv g var val = adjustGitEnv g (addEntry var val)
|
||||
|
||||
{- Use with any action that makes a commit to set metadata. -}
|
||||
commitWithMetaData :: CommitMetaData -> CommitMetaData -> (Repo -> IO a) -> Repo -> IO a
|
||||
commitWithMetaData authormetadata committermetadata a g =
|
||||
a =<< adjustGitEnv g adj
|
||||
where
|
||||
adj = mkadj "AUTHOR" authormetadata
|
||||
. mkadj "COMMITTER" committermetadata
|
||||
mkadj p md = go "NAME" commitName
|
||||
. go "EMAIL" commitEmail
|
||||
. go "DATE" commitDate
|
||||
where
|
||||
go s getv = case getv md of
|
||||
Nothing -> id
|
||||
Just v -> addEntry ("GIT_" ++ p ++ "_" ++ s) v
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue