diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-25 14:59:35 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-25 15:14:47 -0400 |
commit | 063e26fb58d6f835b9325e280f322eb5788ca660 (patch) | |
tree | 433d5bbabf0eeba0ab0e2afd8c9a7994bdb5863d /Git/Env.hs | |
parent | c5df5fd4fa172782fee20f966b04c3793df140a1 (diff) |
add catCommit, with commit object parser
Diffstat (limited to 'Git/Env.hs')
-rw-r--r-- | Git/Env.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Git/Env.hs b/Git/Env.hs index 35a4eb04d..0173513a7 100644 --- a/Git/Env.hs +++ b/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 |