From 2f5baf2d35d91e4423cdcfc01c999214d4c3575f Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 24 Dec 2018 00:10:14 -0500 Subject: [PATCH 1/4] Bump containers upper bound --- hpc-coveralls.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hpc-coveralls.cabal b/hpc-coveralls.cabal index f2acb39..0fa8d79 100644 --- a/hpc-coveralls.cabal +++ b/hpc-coveralls.cabal @@ -60,7 +60,7 @@ library base >= 4 && < 5, bytestring >= 0.10 && <0.11, Cabal, - containers >= 0.5 && <0.6, + containers >= 0.5 && <0.7, cmdargs >= 0.10 && <0.11, curl >= 1.3.8 && <1.4, directory >= 1.2 && <1.4, @@ -81,7 +81,7 @@ executable hpc-coveralls base >= 4 && < 5, bytestring >= 0.10 && <0.11, Cabal, - containers >= 0.5 && <0.6, + containers >= 0.5 && <0.7, cmdargs >= 0.10 && <0.11, curl >= 1.3.8 && <1.4, directory >= 1.2 && <1.4, From cb31d3861d0f95452849351b1544978df84c44e5 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 24 Dec 2018 00:16:19 -0500 Subject: [PATCH 2/4] Bump aeson upper bound --- hpc-coveralls.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hpc-coveralls.cabal b/hpc-coveralls.cabal index 0fa8d79..0c8a988 100644 --- a/hpc-coveralls.cabal +++ b/hpc-coveralls.cabal @@ -56,7 +56,7 @@ library Trace.Hpc.Coveralls.GitInfo, Trace.Hpc.Coveralls.Paths build-depends: - aeson >= 0.7.1 && <1.3, + aeson >= 0.7.1 && <1.5, base >= 4 && < 5, bytestring >= 0.10 && <0.11, Cabal, @@ -77,7 +77,7 @@ executable hpc-coveralls hs-source-dirs: src main-is: HpcCoverallsMain.hs build-depends: - aeson >= 0.7.1 && <1.3, + aeson >= 0.7.1 && <1.5, base >= 4 && < 5, bytestring >= 0.10 && <0.11, Cabal, From 9e131f119a9087478c9189ba1850da9f025f6f86 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 24 Dec 2018 00:18:44 -0500 Subject: [PATCH 3/4] Add upper bound on Cabal Distribution.PackageDescription.Parse is no longer exposed in Cabal 2.4. --- hpc-coveralls.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hpc-coveralls.cabal b/hpc-coveralls.cabal index 0c8a988..377986a 100644 --- a/hpc-coveralls.cabal +++ b/hpc-coveralls.cabal @@ -59,7 +59,7 @@ library aeson >= 0.7.1 && <1.5, base >= 4 && < 5, bytestring >= 0.10 && <0.11, - Cabal, + Cabal <2.4, containers >= 0.5 && <0.7, cmdargs >= 0.10 && <0.11, curl >= 1.3.8 && <1.4, From a2d500316fecb8ee49c034e2781862c8606b96af Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Mon, 24 Dec 2018 14:43:49 -0500 Subject: [PATCH 4/4] Add support for Cabal-2.4 --- hpc-coveralls.cabal | 4 ++-- src/Trace/Hpc/Coveralls/Cabal.hs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hpc-coveralls.cabal b/hpc-coveralls.cabal index 377986a..e3b7dec 100644 --- a/hpc-coveralls.cabal +++ b/hpc-coveralls.cabal @@ -59,7 +59,7 @@ library aeson >= 0.7.1 && <1.5, base >= 4 && < 5, bytestring >= 0.10 && <0.11, - Cabal <2.4, + Cabal >= 2.4 && <2.6, containers >= 0.5 && <0.7, cmdargs >= 0.10 && <0.11, curl >= 1.3.8 && <1.4, @@ -80,7 +80,7 @@ executable hpc-coveralls aeson >= 0.7.1 && <1.5, base >= 4 && < 5, bytestring >= 0.10 && <0.11, - Cabal, + Cabal >= 2.4 && <2.6, containers >= 0.5 && <0.7, cmdargs >= 0.10 && <0.11, curl >= 1.3.8 && <1.4, diff --git a/src/Trace/Hpc/Coveralls/Cabal.hs b/src/Trace/Hpc/Coveralls/Cabal.hs index b303045..8f28a8e 100644 --- a/src/Trace/Hpc/Coveralls/Cabal.hs +++ b/src/Trace/Hpc/Coveralls/Cabal.hs @@ -17,7 +17,12 @@ import Control.Monad.Trans.Maybe import Data.List (intercalate, isSuffixOf) import Distribution.Package import Distribution.PackageDescription +#if MIN_VERSION_Cabal(2,4,0) +import Distribution.PackageDescription.Parsec +import qualified Data.ByteString as BS +#else import Distribution.PackageDescription.Parse +#endif import Distribution.Version import System.Directory @@ -30,6 +35,17 @@ getCabalFile dir = do where isCabal filename = ".cabal" `isSuffixOf` filename && length filename > 6 getPackageNameVersion :: FilePath -> IO (Maybe String) +#if MIN_VERSION_Cabal(2,4,0) +getPackageNameVersion file = do + orig <- BS.readFile file + case runParseResult $ parseGenericPackageDescription orig of + (_warnings, Left _) -> return Nothing + (_warnings, Right gpd) -> return $ Just $ name ++ "-" ++ version + where pkg = package . packageDescription $ gpd + name = unPackageName $ pkgName pkg + version = showVersion (pkgVersion pkg) + showVersion = intercalate "." . map show . versionNumbers +#else getPackageNameVersion file = do orig <- readFile file case parsePackageDescription orig of @@ -39,6 +55,7 @@ getPackageNameVersion file = do name = unPackageName $ pkgName pkg version = showVersion (pkgVersion pkg) showVersion = intercalate "." . map show . versionNumbers +#endif currDirPkgNameVer :: IO (Maybe String) currDirPkgNameVer = runMaybeT $ pkgNameVersion currentDir