Last active
August 29, 2015 14:07
-
-
Save chrisdone/429a22a8f8fd5414e58e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Compile with | |
-- | |
-- ghc --make Status.hs -o ~/.cabal/bin/projects -O2 -threaded | |
-- | |
-- Or run with: | |
-- | |
-- runhaskell Status.hs | |
-- | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import Data.Conduit.Shell | |
import qualified Data.Conduit.Shell.Segments as SH | |
import Data.List | |
import Data.Monoid | |
import System.Directory | |
main :: IO () | |
main = | |
run (do dirs <- SH.strings (ls "-1") | |
cur <- liftIO getCurrentDirectory | |
forM_ dirs | |
(\dir -> | |
do exists <- liftIO (doesDirectoryExist (cur <> "/" <> dir)) | |
unless (not exists) | |
(checkRepo cur dir))) | |
checkRepo cur dir = | |
do cd (cur ++ "/" ++ dir) | |
exists <- liftIO (doesDirectoryExist ".git") | |
when exists | |
(do lines <- SH.strings (git "status") | |
when (any (isPrefixOf "# Changes not staged") lines) | |
(echo (dir <> " has unstaged changes")) | |
when (any (isPrefixOf "# Untracked") lines) | |
(echo (dir <> " has untracked files")) | |
when (any (isPrefixOf "# Changes to be committed") lines) | |
(echo (dir <> " has uncommitted changes")) | |
when (any (isInfixOf "use \"git push\" to publish your local commits") lines) | |
(echo (dir <> " has unpushed commits"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment