@@ -17,16 +17,18 @@
1717-- > panic :: String -> a
1818-- > panic msg = error panicMsg
1919-- > where panicMsg =
20−-- > concat [ "[panic ", $(gitBranch), "@", $(gitHash), dirty, "] ", msg ]
20+-- > concat [ "[panic ", $(gitBranch), "@", $(gitHash)
21+-- > , " (", $(gitCommitCount), " commits in HEAD)"
22+-- > , dirty, "] ", msg ]
2123-- > dirty | $(gitDirty) = " (uncommitted files present)"
2224-- > | otherwise = ""
2325-- >
2426-- > main = panic "oh no!"
2527--
2628-- > % cabal exec runhaskell Example.hs
27−-- > Example.hs: [panic master@4a0a592c37ad908889bd2a7a411923a903ed05a3 (uncommitted files present)] oh no!
29+-- > Example.hs: [panic master@2702e69355c978805064543489c351b61ac6760b (6 commits in HEAD) (uncommitted files present)] oh no!
2830
29−module Development.GitRev (gitHash, gitBranch, gitDirty) where
31+module Development.GitRev (gitHash, gitBranch, gitDirty, gitCommitCount) where
3032
3133import Control.Applicative
3234import Control.Exception
@@ -103,3 +105,8 @@ gitDirty = do
103105 case output of
104106 "" -> conE $ mkName "Prelude.False"
105107 _ -> conE $ mkName "Prelude.True"
108+
109+-- | Return the number of commits in the current head
110+gitCommitCount :: ExpQ
111+gitCommitCount =
112+ stringE =<< runGit ["rev-list", "HEAD", "--count"] "UNKNOWN"