git.iko.soy/typeable/gitrev
on master help sign in
Merge pull request #4 from mulderr/master
6feaf4aAdam C. Foltzer
Example.hs+1
@@ -6,6 +6,7 @@ panic :: String -> a
6panic msg = error panicMsg
6panic msg = error panicMsg
7 where panicMsg =
7 where panicMsg =
8 concat [ "[panic ", $(gitBranch), "@", $(gitHash)
8 concat [ "[panic ", $(gitBranch), "@", $(gitHash)
9+ , " (", $(gitCommitDate), ")"
9 , " (", $(gitCommitCount), " commits in HEAD)"
10 , " (", $(gitCommitCount), " commits in HEAD)"
10 , dirty, "] ", msg ]
11 , dirty, "] ", msg ]
11 dirty | $(gitDirty) = " (uncommitted files present)"
12 dirty | $(gitDirty) = " (uncommitted files present)"
src/Development/GitRev.hs+6−1
@@ -28,7 +28,7 @@
28-- > % cabal exec runhaskell Example.hs
28-- > % cabal exec runhaskell Example.hs
29-- > Example.hs: [panic master@2702e69355c978805064543489c351b61ac6760b (6 commits in HEAD) (uncommitted files present)] oh no!
29-- > Example.hs: [panic master@2702e69355c978805064543489c351b61ac6760b (6 commits in HEAD) (uncommitted files present)] oh no!
30
30
31−module Development.GitRev (gitHash, gitBranch, gitDirty, gitCommitCount) where
31+module Development.GitRev (gitHash, gitBranch, gitDirty, gitCommitCount, gitCommitDate) where
32
32
33import Control.Applicative
33import Control.Applicative
34import Control.Exception
34import Control.Exception
@@ -110,3 +110,8 @@ gitDirty = do
110gitCommitCount :: ExpQ
110gitCommitCount :: ExpQ
111gitCommitCount =
111gitCommitCount =
112 stringE =<< runGit ["rev-list", "HEAD", "--count"] "UNKNOWN"
112 stringE =<< runGit ["rev-list", "HEAD", "--count"] "UNKNOWN"
113+
114+-- | Return the commit date of the current head
115+gitCommitDate :: ExpQ
116+gitCommitDate =
117+ stringE =<< runGit ["log", "HEAD", "-1", "--format=%cd"] "UNKNOWN"