Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdone/429a22a8f8fd5414e58e to your computer and use it in GitHub Desktop.
Save chrisdone/429a22a8f8fd5414e58e to your computer and use it in GitHub Desktop.
-- 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