From cb95a54b579b17b222daa9cf0df5438b5bb3d19f Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Wed, 13 Feb 2019 16:16:28 +0100 Subject: [PATCH 1/5] Handle Cartfile entries with no new lines at EOL --- src/Configuration.hs | 1 + src/Data/Carthage/Cartfile.hs | 42 ++++++++++++++++++++++++++++------- src/Text/Parsec/Utils.hs | 22 +++++++++--------- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/Configuration.hs b/src/Configuration.hs index 0d190ec..fb109d5 100644 --- a/src/Configuration.hs +++ b/src/Configuration.hs @@ -13,6 +13,7 @@ import qualified Data.Text.IO as T import System.Directory import System.FilePath import Types +import Debug.Trace getCartfileEntires :: RomeMonad [CartfileEntry] diff --git a/src/Data/Carthage/Cartfile.hs b/src/Data/Carthage/Cartfile.hs index 01c7fab..5da5c58 100644 --- a/src/Data/Carthage/Cartfile.hs +++ b/src/Data/Carthage/Cartfile.hs @@ -17,6 +17,7 @@ import qualified Text.Parsec as Parsec import qualified Text.Parsec.String as Parsec import qualified Text.Parsec.Utils as Parsec import Data.Carthage.Common +import Debug.Trace newtype Location = Location { unLocation :: String } deriving (Eq, Show, Ord) @@ -55,20 +56,45 @@ quotedContent :: Parsec.Parsec String () String quotedContent = Parsec.char '"' *> Parsec.parseUnquotedString <* Parsec.char '"' -parseCartfileResolvedLine :: Parsec.Parsec String () CartfileEntry -parseCartfileResolvedLine = do +parseCartfileEntry :: Parsec.Parsec String () CartfileEntry +parseCartfileEntry = do hosting <- repoHosting location <- Location <$> quotedContent _ <- Parsec.many1 Parsec.space version <- Version <$> quotedContent return CartfileEntry {..} -parseMaybeCartfileEntry :: Parsec.Parsec String () (Maybe CartfileEntry) -parseMaybeCartfileEntry = - Parsec.optional Parsec.spaces - *> (parseCartfileResolvedLine `Parsec.onceAndConsumeTill` Parsec.endOfLine) - parseCartfileResolved :: MonadIO m => String -> m (Either Parsec.ParseError [CartfileEntry]) parseCartfileResolved = liftIO . Parsec.parseFromFile - (catMaybes <$> Parsec.many (Parsec.try parseMaybeCartfileEntry)) + ( catMaybes + <$> ( (Parsec.many $ do + line <- + Parsec.optional Parsec.endOfLine + *> ( Parsec.try parseEmtpyLine + <|> Parsec.try parseDependency + <|> Parsec.try parseComment + ) + <* Parsec.optional Parsec.endOfLine + case line of + Dependency entry -> + return $ Just entry + _ -> return Nothing + ) + <* Parsec.eof + ) + ) + +data CartfileLine = EmptyLine | Comment | Dependency { entry :: CartfileEntry } deriving (Eq, Show) + +parseDependency :: Parsec.Parsec String () CartfileLine +parseDependency = Dependency <$> parseCartfileEntry + +parseComment :: Parsec.Parsec String () CartfileLine +parseComment = + Parsec.char '#' + >> Parsec.manyTill Parsec.anyChar (Parsec.lookAhead Parsec.endOfLine) + >> return Comment + +parseEmtpyLine :: Parsec.Parsec String () CartfileLine +parseEmtpyLine = Parsec.many1 Parsec.space >> return EmptyLine diff --git a/src/Text/Parsec/Utils.hs b/src/Text/Parsec/Utils.hs index 9d232f4..c8a2cd0 100644 --- a/src/Text/Parsec/Utils.hs +++ b/src/Text/Parsec/Utils.hs @@ -3,7 +3,7 @@ module Text.Parsec.Utils ( parseWhiteSpaces , parseUnquotedString - , onceAndConsumeTill + -- , onceAndConsumeTill ) where @@ -23,13 +23,13 @@ parseUnquotedString = Parsec.many1 (Parsec.noneOf ['"', ' ', '\t', '\n', '\'', '\\', '\r']) --- | @onceOrConsumeTill p@ end@ tries to apply the parser @p@ /once/ and consumes --- | the input until @end@. Returns a `Maybe` of the value of @p@. --- | Thanks to Tobias Mayer, Berlin Haskell Group. -onceAndConsumeTill - :: (Parsec.Stream s Identity Char) - => Parsec.Parsec s u a - -> Parsec.Parsec s u b - -> Parsec.Parsec s u (Maybe a) -onceAndConsumeTill p end = Parsec.optionMaybe (Parsec.try p) <* consume - where consume = Parsec.try end <|> Parsec.anyChar *> consume +-- -- | @onceOrConsumeTill p@ end@ tries to apply the parser @p@ /once/ and consumes +-- -- | the input until @end@. Returns a `Maybe` of the value of @p@. +-- -- | Thanks to Tobias Mayer, Berlin Haskell Group. +-- onceAndConsumeTill +-- :: (Parsec.Stream s Identity Char) +-- => Parsec.Parsec s u a +-- -> Parsec.Parsec s u b +-- -> Parsec.Parsec s u (Maybe a) +-- onceAndConsumeTill p end = Parsec.optionMaybe (Parsec.try p) <* consume +-- where consume = Parsec.try end <|> Parsec.anyChar *> consume From 63b68f13a938051d375c3af57b688cc0f241cea0 Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Wed, 13 Feb 2019 19:15:29 +0100 Subject: [PATCH 2/5] Version bump --- Rome.cabal | 2 +- Rome.podspec | 2 +- app/Main.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Rome.cabal b/Rome.cabal index 9faf80a..df615e0 100644 --- a/Rome.cabal +++ b/Rome.cabal @@ -1,5 +1,5 @@ name: Rome -version: 0.18.1.53 +version: 0.18.2.54 synopsis: A cache for Carthage description: Please see README.md homepage: https://github.com/blender/Rome diff --git a/Rome.podspec b/Rome.podspec index 64341f2..d9a9fc1 100644 --- a/Rome.podspec +++ b/Rome.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Rome' - s.version = '0.18.1.53' + s.version = '0.18.2.54' s.summary = 'A cache tool for Carthage' s.homepage = 'https://github.com/blender/Rome' s.source = { :http => "#{s.homepage}/releases/download/v#{s.version}/rome.zip" } diff --git a/app/Main.hs b/app/Main.hs index e284830..b2195c7 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -10,7 +10,7 @@ import System.Exit romeVersion :: RomeVersion -romeVersion = (0, 18, 1, 53) +romeVersion = (0, 18, 2, 54) From 5d37f0c8e7221886d44631ebce2024b60e4f1a6d Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Thu, 14 Feb 2019 17:56:13 +0100 Subject: [PATCH 3/5] Update travis config --- .travis.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a89c68..231d92e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,9 +40,9 @@ jobs: - brew install bats-core script: - bundle exec danger - - stack $ARGS setup + - stack $ARGS setup -j 2 - stack $ARGS test --no-terminal --haddock --no-haddock-deps - - stack $ARGS build + - stack $ARGS build -j 2 - stack $ARGS sdist - stack $ARGS install - travis_wait 60 bats integration-tests/dynamic-frameworks-ini.bats @@ -77,9 +77,9 @@ jobs: - brew install bats-core script: - bundle exec danger - - stack $ARGS setup + - stack $ARGS setup -j 2 - stack $ARGS test --no-terminal --haddock --no-haddock-deps - - stack $ARGS build + - stack $ARGS build -j 2 - stack $ARGS sdist - stack $ARGS install - travis_wait 60 bats integration-tests/current-framework-yaml.bats @@ -114,9 +114,9 @@ jobs: - brew install bats-core script: - bundle exec danger - - stack $ARGS setup + - stack $ARGS setup -j 2 - stack $ARGS test --no-terminal --haddock --no-haddock-deps - - stack $ARGS build + - stack $ARGS build -j 2 - stack $ARGS sdist - stack $ARGS install - travis_wait 60 bats integration-tests/static-frameworks-ini.bats @@ -126,4 +126,5 @@ cache: directories: - $HOME/.local/bin - $HOME/.stack + - $TRAVIS_BUILD_DIR/.stack-work - vendor/bundle From c8727f7cc99c890773a5383b7b7c1586afe205c8 Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Sat, 16 Feb 2019 02:02:01 +0100 Subject: [PATCH 4/5] Update Utils.hs --- src/Text/Parsec/Utils.hs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Text/Parsec/Utils.hs b/src/Text/Parsec/Utils.hs index c8a2cd0..a94d031 100644 --- a/src/Text/Parsec/Utils.hs +++ b/src/Text/Parsec/Utils.hs @@ -21,15 +21,3 @@ parseWhiteSpaces = parseUnquotedString :: Parsec.Parsec String () String parseUnquotedString = Parsec.many1 (Parsec.noneOf ['"', ' ', '\t', '\n', '\'', '\\', '\r']) - - --- -- | @onceOrConsumeTill p@ end@ tries to apply the parser @p@ /once/ and consumes --- -- | the input until @end@. Returns a `Maybe` of the value of @p@. --- -- | Thanks to Tobias Mayer, Berlin Haskell Group. --- onceAndConsumeTill --- :: (Parsec.Stream s Identity Char) --- => Parsec.Parsec s u a --- -> Parsec.Parsec s u b --- -> Parsec.Parsec s u (Maybe a) --- onceAndConsumeTill p end = Parsec.optionMaybe (Parsec.try p) <* consume --- where consume = Parsec.try end <|> Parsec.anyChar *> consume From 2553465e770fc6b561a876f565ae7742d8e290e3 Mon Sep 17 00:00:00 2001 From: Tommaso Piazza Date: Sat, 16 Feb 2019 02:02:14 +0100 Subject: [PATCH 5/5] Update Utils.hs --- src/Text/Parsec/Utils.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Text/Parsec/Utils.hs b/src/Text/Parsec/Utils.hs index a94d031..6573294 100644 --- a/src/Text/Parsec/Utils.hs +++ b/src/Text/Parsec/Utils.hs @@ -3,7 +3,6 @@ module Text.Parsec.Utils ( parseWhiteSpaces , parseUnquotedString - -- , onceAndConsumeTill ) where