Skip to content

Commit a0cd8fe

Browse files
authored
Merge pull request acfoltzer#12 from vlopezj/untracked
Allow ignoring untracked files when checking whether the repo is dirty
2 parents 33b104f + 5a3c6ec commit a0cd8fe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Development/GitRev.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

3737
import Control.Exception
3838
import 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
140149
gitCommitCount :: ExpQ
141150
gitCommitCount =

0 commit comments

Comments
 (0)