Copyright | (c) 2015 Adam C. Foltzer |
---|---|
License | BSD3 |
Maintainer | acfoltzer@galois.com |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Some handy Template Haskell splices for including the current git
hash and branch in the code of your project. Useful for including
in panic messages, --version
output, or diagnostic info for more
informative bug reports.
{-# LANGUAGE TemplateHaskell #-} import Development.GitRev panic :: String -> a panic msg = error panicMsg where panicMsg = concat [ "[panic ", $(gitBranch), "@", $(gitHash), dirty, "] ", msg ] dirty | $(gitDirty) = " (uncommitted files present)" | otherwise = "" main = panic "oh no!"
% cabal exec runhaskell Example.hs Example.hs: [panic master@4a0a592c37ad908889bd2a7a411923a903ed05a3 (uncommitted files present)] oh no!
Documentation
Return the hash of the current git commit, or UNKNOWN
if not in
a git repository
Return the branch (or tag) name of the current git commit, or UNKNOWN
if not in a git repository. For detached heads, this will just be
HEAD