git.iko.soy/typeable/gitrev
on master help sign in
2 files changed+18−4
since splitsnapshots
unifiedsplit
gitrev.cabal+1−1 src/Development/GitRev.hs+17−3
gitrev.cabal+1−1
@@ -1,5 +1,5 @@
11name: gitrev
2−version: 1.3.0
2+version: 1.3.1
33synopsis: Compile git revision info into Haskell projects
44homepage: https://github.com/acfoltzer/gitrev
55license: BSD3
src/Development/GitRev.hs+17−3
@@ -32,7 +32,15 @@
3232-- > % cabal exec runhaskell Example.hs
3333-- > Example.hs: [panic master@2ae047ba5e4a6f0f3e705a43615363ac006099c1 (Mon Jan 11 11:50:59 2016 -0800) (14 commits in HEAD) (uncommitted files present)] oh no!
3434
35−module Development.GitRev (gitHash, gitBranch, gitDirty, gitDirtyTracked, gitCommitCount, gitCommitDate) where
35+module Development.GitRev
36+ ( gitBranch
37+ , gitCommitCount
38+ , gitCommitDate
39+ , gitDescribe
40+ , gitDirty
41+ , gitDirtyTracked
42+ , gitHash
43+ ) where
3644
3745import Control.Exception
3846import Control.Monad
@@ -58,7 +66,7 @@ runGit args def useIdx = do
5866 if gitFound
5967 then do
6068 -- a lot of bookkeeping to record the right dependencies
61− pwd <- runIO getGitDirectory
69+ pwd <- runIO getDotGit
6270 let hd = pwd </> ".git" </> "HEAD"
6371 index = pwd </> ".git" </> "index"
6472 packedRefs = pwd </> ".git" </> "packed-refs"
@@ -113,7 +121,7 @@ getDotGit = do
113121getGitRoot :: IO FilePath
114122getGitRoot = do
115123 pwd <- getCurrentDirectory
116− (code, out, err) <-
124+ (code, out, _) <-
117125 readProcessWithExitCode "git" ["rev-parse", "--show-toplevel"] ""
118126 case code of
119127 ExitSuccess -> return $ takeWhile (/= '\n') out
@@ -137,6 +145,12 @@ gitBranch :: ExpQ
137145gitBranch =
138146 stringE =<< runGit ["rev-parse", "--abbrev-ref", "HEAD"] "UNKNOWN" IdxNotUsed
139147
148+-- | Return the long git description for the current git commit, or
149+-- @UNKNOWN@ if not in a git repository.
150+gitDescribe :: ExpQ
151+gitDescribe =
152+ stringE =<< runGit ["describe", "--long", "--always"] "UNKNOWN" IdxNotUsed
153+
140154-- | Return @True@ if there are non-committed files present in the
141155-- repository
142156gitDirty :: ExpQ