Skip to content

Commit 5a3c6ec

Browse files
committed
add gitDirtyTracked, which ignores untracked files
1 parent c5496f3 commit 5a3c6ec

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
@@ -29,7 +29,7 @@
2929
-- > % cabal exec runhaskell Example.hs
3030
-- > Example.hs: [panic master@2ae047ba5e4a6f0f3e705a43615363ac006099c1 (Mon Jan 11 11:50:59 2016 -0800) (14 commits in HEAD) (uncommitted files present)] oh no!
3131

32-
module Development.GitRev (gitHash, gitBranch, gitDirty, gitCommitCount, gitCommitDate) where
32+
module Development.GitRev (gitHash, gitBranch, gitDirty, gitDirtyTracked, gitCommitCount, gitCommitDate) where
3333

3434
import Control.Applicative
3535
import Control.Exception
@@ -112,6 +112,15 @@ gitDirty = do
112112
"" -> conE falseName
113113
_ -> conE trueName
114114

115+
-- | Return @True@ if there are non-commited changes to tracked files
116+
-- present in the repository
117+
gitDirtyTracked :: ExpQ
118+
gitDirtyTracked = do
119+
output <- runGit ["status", "--porcelain","--untracked-files=no"] "" IdxUsed
120+
case output of
121+
"" -> conE falseName
122+
_ -> conE trueName
123+
115124
-- | Return the number of commits in the current head
116125
gitCommitCount :: ExpQ
117126
gitCommitCount =

0 commit comments

Comments
 (0)