diff --git a/src/Development/GitRev.hs b/src/Development/GitRev.hs index b664692..a84bf47 100644 --- a/src/Development/GitRev.hs +++ b/src/Development/GitRev.hs @@ -40,6 +40,7 @@ module Development.GitRev , gitDirty , gitDirtyTracked , gitHash + , gitHashShort ) where import Control.Exception @@ -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"