hpack 0.34.1 → 0.34.2
raw patch · 9 files changed
+42/−24 lines, 9 filesdep ~CabalPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
Files
- CHANGELOG.md +3/−0
- hpack.cabal +5/−5
- src/Hpack/Config.hs +4/−0
- src/Hpack/License.hs +0/−4
- src/Hpack/Syntax/Dependencies.hs +10/−1
- src/Hpack/Syntax/DependencyVersion.hs +0/−9
- test/EndToEndSpec.hs +9/−1
- test/Hpack/LicenseSpec.hs +0/−4
- test/Hpack/Syntax/DependenciesSpec.hs +11/−0
CHANGELOG.md view
@@ -1,3 +1,6 @@+## Changes in 0.34.2+ - Accept subcomponents as dependencies (close #382)+ ## Changes in 0.34.1 - Fix a bug in `github: ...` introduced with `0.34.0` (f63eb19b956517b4dd8e28dc5785be5889a99298)
hpack.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.1.+-- This file has been generated from package.yaml by hpack version 0.34.2. -- -- see: https://github.com/sol/hpack name: hpack-version: 0.34.1+version: 0.34.2 synopsis: A modern format for Haskell packages description: See README at <https://github.com/sol/hpack#readme> category: Development@@ -27,7 +27,7 @@ src ghc-options: -Wall build-depends:- Cabal >=2.2+ Cabal >=3.0.0.0 , Glob >=0.9.0 , aeson >=1.4.3.0 , base >=4.9 && <5@@ -83,7 +83,7 @@ driver ghc-options: -Wall build-depends:- Cabal >=2.2+ Cabal >=3.0.0.0 , Glob >=0.9.0 , aeson >=1.4.3.0 , base >=4.9 && <5@@ -119,7 +119,7 @@ ghc-options: -Wall cpp-options: -DTEST build-depends:- Cabal >=2.2+ Cabal >=3.0.0.0 , Glob >=0.9.0 , HUnit >=1.6.0.0 , QuickCheck
src/Hpack/Config.hs view
@@ -739,6 +739,7 @@ makeVersion [2,2] <$ guard (sectionSatisfies (not . null . sectionCxxSources) sect) , makeVersion [2,2] <$ guard (sectionSatisfies (not . null . sectionCxxOptions) sect) , makeVersion [2,0] <$ guard (sectionSatisfies (any hasMixins . unDependencies . sectionDependencies) sect)+ , makeVersion [3,0] <$ guard (sectionSatisfies (any hasSubcomponents . Map.keys . unDependencies . sectionDependencies) sect) ] ++ map versionFromSystemBuildTool systemBuildTools where versionFromSystemBuildTool name@@ -797,6 +798,9 @@ hasMixins :: DependencyInfo -> Bool hasMixins (DependencyInfo mixins _) = not (null mixins)++ hasSubcomponents :: String -> Bool+ hasSubcomponents = elem ':' decodeValue :: FromValue a => ProgramName -> FilePath -> Value -> Warnings (Errors IO) a decodeValue (ProgramName programName) file value = do
src/Hpack/License.hs view
@@ -10,11 +10,7 @@ import Distribution.Version (mkVersion) import qualified Distribution.License as Cabal import qualified Distribution.SPDX.License as SPDX-#if MIN_VERSION_Cabal(3,0,0) import Distribution.Parsec (eitherParsec)-#else-import Distribution.Parsec.Class (eitherParsec)-#endif import qualified Data.License.Infer as Infer
src/Hpack/Syntax/Dependencies.hs view
@@ -9,9 +9,12 @@ import qualified Control.Monad.Fail as Fail import Data.Text (Text)+import Data.List import qualified Data.Text as T import Data.Semigroup (Semigroup(..)) import qualified Distribution.Package as D+import qualified Distribution.Types.LibraryName as D+import Distribution.Pretty (prettyShow) import Data.Map.Lazy (Map) import qualified Data.Map.Lazy as Map import GHC.Exts@@ -64,4 +67,10 @@ parseDependency subject = fmap fromCabal . cabalParse subject . T.unpack where fromCabal :: D.Dependency -> (String, DependencyVersion)- fromCabal d = (D.unPackageName $ D.depPkgName d, DependencyVersion Nothing . versionConstraintFromCabal $ D.depVerRange d)+ fromCabal d = (toName (D.depPkgName d) (toList $ D.depLibraries d), DependencyVersion Nothing . versionConstraintFromCabal $ D.depVerRange d)++ toName :: D.PackageName -> [D.LibraryName] -> String+ toName package components = prettyShow package <> case components of+ [D.LMainLibName] -> ""+ [D.LSubLibName lib] -> ":" <> prettyShow lib+ xs -> ":{" <> (intercalate "," $ map prettyShow [name | D.LSubLibName name <- xs]) <> "}"
src/Hpack/Syntax/DependencyVersion.hs view
@@ -36,13 +36,8 @@ import Distribution.Version (VersionRangeF(..)) import qualified Distribution.Version as D -#if MIN_VERSION_Cabal(3,0,0) import qualified Distribution.Parsec as D import qualified Distribution.Pretty as D-#else-import qualified Distribution.Parsec.Class as D-import qualified Distribution.Text as D-#endif import Data.Aeson.Config.FromValue @@ -156,11 +151,7 @@ versionConstraintFromCabal range | D.isAnyVersion range = AnyVersion | otherwise = VersionRange . renderStyle style .-#if MIN_VERSION_Cabal(3,0,0) D.pretty-#else- D.disp-#endif $ toPreCabal2VersionRange range where style = Style OneLineMode 0 0
test/EndToEndSpec.hs view
@@ -63,7 +63,6 @@ it "fails on unsupported spec-version" $ do [i| spec-version: 25.0- dependencies: foo == bar |] `shouldFailWith` ("The file package.yaml requires version 25.0 of the Hpack package specification, however this version of hpack only supports versions up to " ++ showVersion Hpack.version ++ ". Upgrading to the latest version of hpack may resolve this issue.") it "fails on unsupported spec-version from defaults" $ do@@ -610,6 +609,15 @@ build-depends: base |]++ it "accepts dependencies with subcomponents" $ do+ [i|+ executable:+ dependencies: foo:bar+ |] `shouldRenderTo` (executable_ "foo" [i|+ build-depends:+ foo:bar+ |]) {packageCabalVersion = "3.0"} it "accepts list of dependencies" $ do [i|
test/Hpack/LicenseSpec.hs view
@@ -7,11 +7,7 @@ import Data.String.Interpolate import Distribution.Pretty (prettyShow)-#if MIN_VERSION_Cabal(3,0,0) import Distribution.Parsec (simpleParsec)-#else-import Distribution.Parsec.Class (simpleParsec)-#endif import qualified Distribution.License as Cabal import Hpack.License
test/Hpack/Syntax/DependenciesSpec.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE OverloadedStrings #-} module Hpack.Syntax.DependenciesSpec (spec) where import Helper@@ -18,6 +19,16 @@ spec :: Spec spec = do+ describe "parseDependency" $ do+ it "accepts dependencies" $ do+ parseDependency "dependency" "foo" `shouldReturn` ("foo", DependencyVersion Nothing AnyVersion)++ it "accepts dependencies with a subcomponent" $ do+ parseDependency "dependency" "foo:bar" `shouldReturn` ("foo:bar", DependencyVersion Nothing AnyVersion)++ it "accepts dependencies with multiple subcomponents" $ do+ parseDependency "dependency" "foo:{bar,baz}" `shouldReturn` ("foo:{bar,baz}", DependencyVersion Nothing AnyVersion)+ describe "fromValue" $ do context "when parsing Dependencies" $ do context "with a scalar" $ do