git.iko.soy/typeable/gitrev
on master help sign in
add gitDirtyTracked, which ignores untracked files
commit5a3c6ec7afb94037ce824e82a9cd8f15805d86cd authorVíctor López Juan <victor@lopezjuan.com> dateSat 15 Oct 2016, 12:01 (10 years ago) parentc5496f3
1 file changed+10−1
src/Development/GitRev.hs+10−1
src/Development/GitRev.hs+10−1
@@ -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
3434import Control.Applicative
3535import 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
116125gitCommitCount :: ExpQ
117126gitCommitCount =