Skip to content

Commit

Permalink
Skipping malformed lines in Cartfile.resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
tmspzz committed Apr 4, 2017
1 parent 382516b commit 340ebbd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Rome.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Rome
version: 0.10.1.22
version: 0.10.2.23
synopsis: An S3 cache for Carthage
description: Please see README.md
homepage: https://github.com/blender/Rome
Expand Down
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Options.Applicative as Opts


romeVersion :: String
romeVersion = "0.10.1.22"
romeVersion = "0.10.2.23"



Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Types

getCartfileEntires :: RomeMonad [CartfileEntry]
getCartfileEntires = do
eitherCartfileEntries <- liftIO $ parseCartfileResolved cartfileResolved
eitherCartfileEntries <- parseCartfileResolved cartfileResolved
case eitherCartfileEntries of
Left e -> throwError $ "Carfile.resolved parse error: " ++ show e
Right cartfileEntries -> return cartfileEntries
Expand Down
15 changes: 11 additions & 4 deletions src/Data/Carthage/Cartfile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import qualified Text.Parsec as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Utils as Parsec

import Control.Monad.Trans (MonadIO, liftIO)
import Data.Carthage.Common
import Data.Maybe (fromJust, isJust)


newtype Location = Location { unLocation :: String }
deriving (Eq, Show, Ord)
Expand Down Expand Up @@ -45,7 +48,7 @@ parseGit :: Parsec.Parsec String () RepoHosting
parseGit = Parsec.string "git" >> Parsec.many1 Parsec.space >> pure Git

repoHosting :: Parsec.Parsec String () RepoHosting
repoHosting = Parsec.try parseGit <|> parseGitHub
repoHosting = Parsec.try parseGit <|> Parsec.try parseGitHub

quotedContent :: Parsec.Parsec String () String
quotedContent = do
Expand All @@ -60,8 +63,12 @@ parseCartfileResolvedLine = do
location <- fmap Location quotedContent
Parsec.many1 Parsec.space
version <- fmap Version quotedContent
Parsec.endOfLine
return CartfileEntry {..}

parseCartfileResolved :: String -> IO (Either Parsec.ParseError [CartfileEntry])
parseCartfileResolved = Parsec.parseFromFile (Parsec.many1 (Parsec.optional Parsec.spaces >> parseCartfileResolvedLine))
parseCartfileResolved :: MonadIO m => String -> m (Either Parsec.ParseError [CartfileEntry])
parseCartfileResolved f = liftIO $ do
parseResult <- Parsec.parseFromFile (Parsec.many1 (Parsec.optional Parsec.spaces
>> Parsec.optionMaybe parseCartfileResolvedLine
>>= \cartFileLines -> Parsec.manyTill Parsec.anyChar Parsec.endOfLine
>> return cartFileLines)) f
return $ parseResult >>= \r -> pure [fromJust x | x <- r, isJust x]

0 comments on commit 340ebbd

Please sign in to comment.