Various pieces of information about a Git repository.
Modulegithash-0.1.7.0Haskell2010
GitHash
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 GitHash
panic :: String -> a
panic msg = error panicMsg
where panicMsg =
concat [ "[panic ", giBranch gi, "@", giHash gi
, " (", giCommitDate gi, ")"
, " (", show (giCommitCount gi), " commits in HEAD)"
, dirty, "] ", msg ]
dirty | giDirty gi = " (uncommitted files present)"
| otherwise = ""
gi = $$tGitInfoCwd
main = panic "oh no!"% stack runghc Example.hs
Example.hs: [panic master@2ae047ba5e4a6f0f3e705a43615363ac006099c1 (Mon Jan 11 11:50:59 2016 -0800) (14 commits in HEAD) (uncommitted files present)] oh no!WARNING: None of this will work in a git repository without any commits.
- 2 types
- 15 values
- Packagegithash-0.1.7.0
- Exports17
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceGitHash.hs
Types
2 declarationsExceptions which can occur when using this library's functions.
Instances3Eq, Show, Exception
Eq GitHashExceptionDefined in githash-0.1.7.0 · GitHashShow GitHashExceptionDefined in githash-0.1.7.0 · GitHashException GitHashExceptionDefined in githash-0.1.7.0 · GitHash
Getters
The hash of the most recent commit.
The hash of the most recent commit.
The message of the most recent commit.
The output of git describe --always for the most recent commit.
The output of git describe --always --tags for the most recent commit.
The files used to determine whether recompilation is necessary in splices.
Creators
2 declarationsGet the GitInfo for the given root directory. Root directory
should be the directory containing the .git directory.
Get the root directory of the Git repo containing the given file path.
Template Haskell
4 declarationsLoad up the GitInfo value at compile time for the given directory. Compilation fails if no info is available.
Load up the GitInfo value at compile time for the current working directory.
Try to load up the GitInfo value at compile time for the given directory.
Try to load up the GitInfo value at compile time for the current working directory.