From 51cdc488c29b9e0754379ab23a2797d54b621ef6 Mon Sep 17 00:00:00 2001 From: Olivier Verdier Date: Sat, 16 Jan 2016 22:53:13 +0100 Subject: [PATCH] trailing spaces --- src/app/Main.hs | 2 +- src/src/BranchParse.hs | 20 ++++++++++---------- src/src/Utils.hs | 10 ++++------ src/test/TestBranchParse.hs | 13 ++++++------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/app/Main.hs b/src/app/Main.hs index 50332f02..1a9fbcea 100644 --- a/src/app/Main.hs +++ b/src/app/Main.hs @@ -12,7 +12,7 @@ successOrNothing (exitCode, output, _) = if exitCode == ExitSuccess then Just output else Nothing safeRun :: String -> [String] -> IO (Maybe String) -safeRun command arguments = +safeRun command arguments = do -- IO output <- readProcessWithExitCode command arguments "" return (successOrNothing output) diff --git a/src/src/BranchParse.hs b/src/src/BranchParse.hs index 9ee8de28..acefd364 100644 --- a/src/src/BranchParse.hs +++ b/src/src/BranchParse.hs @@ -1,7 +1,7 @@ module BranchParse where import Control.Applicative (liftA, liftA2) -import Text.Parsec (digit, string, char, eof, anyChar, +import Text.Parsec (digit, string, char, eof, anyChar, many, many1, manyTill, noneOf, between, parse, ParseError, (<|>), try) import Text.Parsec.String (Parser) @@ -48,7 +48,7 @@ isValidBranch b = not (or (isForbidden b)) where instance Arbitrary Branch where - arbitrary = + arbitrary = do -- Gen branch <- arbitrary `suchThat` isValidBranch return (MkBranch branch) @@ -63,7 +63,7 @@ data BranchInfo = MkBranchInfo Branch (Maybe Remote) deriving (Eq, Show) type MBranchInfo = Maybe BranchInfo newRepo :: Parser MBranchInfo -newRepo = +newRepo = do -- Parsec string "Initial commit on " branch <- many anyChar @@ -72,20 +72,20 @@ newRepo = return (Just bi) noBranch :: Parser MBranchInfo -noBranch = +noBranch = do -- Parsec manyTill anyChar (try (string " (no branch)")) eof return Nothing trackedBranch :: Parser Branch -trackedBranch = +trackedBranch = do -- Parsec b <- manyTill anyChar (try (string "...")) return (MkBranch b) branchRemoteTracking :: Parser MBranchInfo -branchRemoteTracking = +branchRemoteTracking = do -- Parsec branch <- trackedBranch tracking <- many (noneOf " ") @@ -97,7 +97,7 @@ branchRemoteTracking = branchRemote :: Parser MBranchInfo -branchRemote = +branchRemote = do -- Parsec branch <- trackedBranch tracking <- many (noneOf " ") @@ -107,7 +107,7 @@ branchRemote = return (Just bi) branchOnly :: Parser MBranchInfo -branchOnly = +branchOnly = do -- Parsec branch <- many (noneOf " ") eof @@ -115,7 +115,7 @@ branchOnly = return (Just bi) branchParser :: Parser MBranchInfo -branchParser = +branchParser = try noBranch <|> try newRepo <|> try branchRemoteTracking @@ -132,7 +132,7 @@ inBrackets :: Parser Distance inBrackets = between (char '[') (char ']') (behind <|> try aheadBehind <|> ahead) makeAheadBehind :: String -> (Int -> Distance) -> Parser Distance -makeAheadBehind name constructor = +makeAheadBehind name constructor = do -- Parsec string (name ++ " ") dist <- many1 digit diff --git a/src/src/Utils.hs b/src/src/Utils.hs index 192b9e94..eb06d41e 100644 --- a/src/src/Utils.hs +++ b/src/src/Utils.hs @@ -20,20 +20,20 @@ processBranch = rightOrNothing . branchInfo processGitStatus :: [String] -> Maybe GitInfo processGitStatus [] = Nothing -processGitStatus (branchLine:statusLines) = +processGitStatus (branchLine:statusLines) = do -- Maybe mbranch <- processBranch branchLine status <- processStatus statusLines return (MkGitInfo mbranch status) showStatusNumbers :: Status Int -> [String] -showStatusNumbers (MakeStatus s x c t) = +showStatusNumbers (MakeStatus s x c t) = do -- List nb <- [s, x, c, t] return (show nb) showRemoteNumbers :: Maybe Remote -> [String] -showRemoteNumbers mremote = +showRemoteNumbers mremote = do -- List ab <- [ahead, behind] return (show ab) @@ -55,7 +55,7 @@ branchOrHashWith c (Just hash) Nothing = MkBranchInfo (MkBranch (c : getHash has branchOrHashWith _ Nothing _ = MkBranchInfo (MkBranch "") Nothing showGitInfo :: Maybe Hash - -> GitInfo + -> GitInfo -> [String] showGitInfo mhash (MkGitInfo bi stat) = branchInfoString ++ showStatusNumbers stat where @@ -67,5 +67,3 @@ stringsFromStatus :: Maybe Hash stringsFromStatus h status = do -- List processed <- processGitStatus (lines status) return (showGitInfo h processed) - - diff --git a/src/test/TestBranchParse.hs b/src/test/TestBranchParse.hs index ccb9ec73..91fb8a68 100644 --- a/src/test/TestBranchParse.hs +++ b/src/test/TestBranchParse.hs @@ -18,7 +18,7 @@ checkRight b s = expectRight b (branchInfo ("## " ++ s)) -- gitRep (MkBranchInfo (MkBranch branch) Nothing) = branch -- gitRep (MkBranchInfo (MkBranch branch) (MkRemote (Just (MkBranch rem)) Nothing)) = branch ++ "..." ++ rem -- gitRep (MkBranchInfo (MkBranch branch) (MkRemote (Just (MkBranch rem)) (Just dis))) = gitRep (MkBranchInfo branch $ MkRemote (Just rem) Nothing) ++ show dis --- +-- {- Test -} propNoBranch :: Branch -> Bool @@ -29,13 +29,13 @@ propNoBranch b = propNewRepo :: Branch -> Bool propNewRepo b = - checkRight + checkRight (Just (MkBranchInfo b Nothing)) ("Initial commit on " ++ show b) propBranchOnly :: Branch -> Bool -propBranchOnly b = - checkRight +propBranchOnly b = + checkRight (Just (MkBranchInfo b Nothing)) (show b) @@ -48,8 +48,8 @@ propBranchRemote b t = remote = Just (MkRemote t Nothing) propBranchRemoteTracking :: Branch -> Branch -> Distance -> Bool -propBranchRemoteTracking b t distance = - checkRight +propBranchRemoteTracking b t distance = + checkRight (Just (MkBranchInfo b remote)) (show b ++ "..." ++ show t ++ " " ++ show distance) where @@ -74,4 +74,3 @@ main :: IO() main = do -- IO results <- runTests unless (all isSuccess results) exitFailure -