From 15d27d10cbf7d852014b8b4f6f033f3630bebf30 Mon Sep 17 00:00:00 2001 From: Bartosz Przygoda Date: Mon, 11 Sep 2017 21:44:53 +0200 Subject: [PATCH] Add gitHashShort to allow obtain shorter (yet still unique) hashes --- src/Development/GitRev.hs | 5 +++++ 1 file changed, 5 insertions(+) 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"