git.iko.soy/typeable/gitrev
on master help sign in
Merge pull request #12 from vlopezj/untracked

Allow ignoring untracked files when checking whether the repo is dirty

commita0cd8feca98798c6e591a62d9e634ea102bc2892 authorAdam C. Foltzer <acfoltzer@gmail.com> dateThu 16 Mar 2017, 19:07 (10 years ago) parent33b104f5a3c6ec
1 file changed+10−1
src/Development/GitRev.hs+10−1
src/Development/GitRev.hs+10−1
@@ -32,7 +32,7 @@
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, gitCommitCount, gitCommitDate) where
35+module Development.GitRev (gitHash, gitBranch, gitDirty, gitDirtyTracked, gitCommitCount, gitCommitDate) where
3636
3737import Control.Exception
3838import Control.Monad
@@ -136,6 +136,15 @@ gitDirty = do
136136 "" -> conE falseName
137137 _ -> conE trueName
138138
139+-- | Return @True@ if there are non-commited changes to tracked files
140+-- present in the repository
141+gitDirtyTracked :: ExpQ
142+gitDirtyTracked = do
143+ output <- runGit ["status", "--porcelain","--untracked-files=no"] "" IdxUsed
144+ case output of
145+ "" -> conE falseName
146+ _ -> conE trueName
147+
139148-- | Return the number of commits in the current head
140149gitCommitCount :: ExpQ
141150gitCommitCount =