Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Add gitHashShort to allow obtain shorter (yet still unique) hashes #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Development/GitRev.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Development.GitRev
, gitDirty
, gitDirtyTracked
, gitHash
, gitHashShort
) where

import Control.Exception
Expand Down Expand Up @@ -138,6 +139,10 @@ gitHash :: ExpQ
gitHash =
stringE =<< runGit ["rev-parse", "HEAD"] "UNKNOWN" IdxNotUsed

gitHashShort :: Int -> ExpQ
gitHashShort len =
stringE =<< runGit ["rev-parse", "--short=" ++ show len, "HEAD"] "UNKNOWN" IdxNotUsed

-- | 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"
Expand Down