cr 1.1 → 1.2
raw patch · 2 files changed
+16/−8 lines, 2 files
Files
Cr.hs view
@@ -27,6 +27,7 @@ data Modes = Init { initCommit :: Commit } | Review+ | Todo deriving ( Show, Data, Typeable ) -- FIXME Move all the config related things to a separate module.@@ -44,9 +45,10 @@ [ Init { initCommit = def &= typ "COMMIT" &= argPos 0 &= opt ("HEAD" :: String) } &= help "initialize cr for this repo" , Review &= help "review new changes"+ , Todo &= help "what's next" ] &= program "cr"- &= summary "cr v1 - Simplified code review"+ &= summary "cr v1.2 - Simplified code review" readConfig :: IO Config readConfig = do@@ -89,17 +91,18 @@ shortenCommit :: Commit -> Commit shortenCommit = Prelude.take 7 -cdToRepoRoot :: IO ()+cdToRepoRoot :: Sh () cdToRepoRoot = do- gitHere <- doesDirectoryExist ".git"+ gitHere <- io $ doesDirectoryExist ".git" when (not gitHere) $ do- wd <- getWorkingDirectory+ wd <- io $ getWorkingDirectory if wd == "/"- then do+ then io $ do putStrLn "this doesn't look like a git repo" exitFailure else do- changeWorkingDirectory ".."+ io $ changeWorkingDirectory ".."+ cd ".." cdToRepoRoot -- FIXME Proper error handling: user should not see git errors.@@ -108,7 +111,7 @@ -- FIXME Add support for `cr todo`. main :: IO () main = shellyNoDir $ silently $ do- io cdToRepoRoot+ cdToRepoRoot opts <- liftIO $ cmdArgs $ modes crModes case opts of Init commit -> do@@ -130,3 +133,8 @@ _ <- interactiveProcess "git" ["diff", fromString commit, "HEAD"] promptYN (printf "Mark as %s reviewed?" (shortenCommit commit')) $ do io_ $ writeFile ".cr" (show (V1 commit'))+ Todo -> do+ print_stdout True (run_ "grep" [ "-RE", "FIXME|TODO|XXX"+ , "--exclude-dir", ".git"+ , "--binary-files", "without-match" ])+ `catchany_sh` (\_ -> return ())
cr.cabal view
@@ -1,5 +1,5 @@ Name: cr-Version: 1.1+Version: 1.2 Cabal-Version: >= 1.8 License: GPL-3 License-File: LICENSE