Skip to content

Commit

Permalink
parse leading hash signs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierverdier committed Feb 3, 2015
1 parent b4b804f commit 10ce328
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/BranchParse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ branchParser =
<|> try branchRemote
<|> branchOnly

branchParser' :: Parser BranchInfo
branchParser' = (string "## ") >> branchParser

inBrackets :: Parser Distance
inBrackets = between (char '[') (char ']') (behind <|> try aheadBehind <|> ahead)
Expand All @@ -116,7 +118,7 @@ aheadBehind =
<*> behind

branchInfo :: String -> Either ParseError BranchInfo
branchInfo = parse branchParser ""
branchInfo = parse branchParser' ""

pairFromDistance :: Distance -> (Int, Int)
pairFromDistance (Ahead n) = (n,0)
Expand Down
2 changes: 1 addition & 1 deletion src/TestBranchParse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Control.Monad (forM, unless)
{- Helper to tackle the Either type -}

checkRight :: BranchInfo -> String -> Bool
checkRight b s = expectRight b $ branchInfo s
checkRight b s = expectRight b $ branchInfo $ "## " ++ s
where
expectRight expected computed = case computed of
Left _ -> False
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rightOrNothing :: Either a b -> Maybe b
rightOrNothing = either (const Nothing) Just

processBranch :: String -> Maybe BranchInfo
processBranch = rightOrNothing . branchInfo . drop 3
processBranch = rightOrNothing . branchInfo

processGitStatus :: [String] -> Maybe (BranchInfo, Status Int)
processGitStatus [] = Nothing
Expand Down

0 comments on commit 10ce328

Please sign in to comment.