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.
Most of the complication in the GitHash module is due to the various
places the current git hash might be stored:
Detached HEAD: the hash is in .git/HEAD
On a branch or tag: the hash is in a file pointed to by .git/HEAD
in a location like .git/refs/heads
On a branch or tag but in a repository with packed refs: the hash is
in .git/packed-refs
These situations all arise under normal development workflows, but
there might be further scenarios that cause problems. Let me know if
you run into them!
Changes
ChangeLog for githash
0.1.7.0
Expose giFiles to users.
0.1.6.3
Specify protocol.file.allow=always for latest git #28
0.1.6.2
Fixed bugs; now this library’s Template Haskell functions are much more
likely on recompilation to detect Git update that doesn’t affect workspace:
e.g. git switch -c <new_branch> (equivalently
git checkout -b <new_branch>) and git commit --amend --only.
Implemented in #23.