hpack 0.38.2 → 0.38.3
raw patch · 8 files changed
+47/−18 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Hpack.Config: Package :: CabalVersion -> String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> [String] -> [String] -> [String] -> BuildType -> Maybe String -> [FilePath] -> [String] -> [Flag] -> [Path] -> [Path] -> [Path] -> [Path] -> Maybe FilePath -> Maybe SourceRepository -> Maybe CustomSetup -> Maybe (Section Library) -> Map String (Section Library) -> Map String (Section Executable) -> Map String (Section Executable) -> Map String (Section Executable) -> [Verbatim] -> Package
+ Hpack.Config: Package :: CabalVersion -> String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> [String] -> Maybe String -> [String] -> [String] -> [String] -> BuildType -> Maybe String -> [FilePath] -> [String] -> [Flag] -> [Path] -> [Path] -> [Path] -> [Path] -> Maybe FilePath -> Maybe SourceRepository -> Maybe CustomSetup -> Maybe (Section Library) -> Map String (Section Library) -> Map String (Section Executable) -> Map String (Section Executable) -> Map String (Section Executable) -> [Verbatim] -> Package
- Hpack.Config: [packageCategory] :: Package -> Maybe String
+ Hpack.Config: [packageCategory] :: Package -> [String]
Files
- CHANGELOG.md +3/−0
- hpack.cabal +3/−2
- resources/test/hpack.cabal +3/−2
- src/Hpack/Config.hs +4/−4
- src/Hpack/Render.hs +14/−8
- src/Hpack/Render/Dsl.hs +1/−1
- test/EndToEndSpec.hs +18/−0
- test/Hpack/ConfigSpec.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,6 @@+## Changes in 0.38.3+ - Accept a list for `category` (see #624)+ ## Changes in 0.38.2 - Infer `cabal-version: 3.12` when `PackageInfo_*` is used (see #620)
hpack.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hpack-version: 0.38.2+version: 0.38.3 synopsis: A modern format for Haskell packages description: See README at <https://github.com/sol/hpack#readme> category: Development@@ -17,8 +17,9 @@ license-file: LICENSE build-type: Simple extra-source-files:- CHANGELOG.md resources/test/hpack.cabal+extra-doc-files:+ CHANGELOG.md source-repository head type: git
resources/test/hpack.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hpack-version: 0.38.2+version: 0.38.3 synopsis: A modern format for Haskell packages description: See README at <https://github.com/sol/hpack#readme> category: Development@@ -17,8 +17,9 @@ license-file: LICENSE build-type: Simple extra-source-files:- CHANGELOG.md resources/test/hpack.cabal+extra-doc-files:+ CHANGELOG.md source-repository head type: git
src/Hpack/Config.hs view
@@ -148,7 +148,7 @@ , packageDescription = Nothing , packageHomepage = Nothing , packageBugReports = Nothing- , packageCategory = Nothing+ , packageCategory = [] , packageStability = Nothing , packageAuthor = [] , packageMaintainer = []@@ -591,7 +591,7 @@ , packageConfigDescription :: Maybe String , packageConfigHomepage :: Maybe (Maybe String) , packageConfigBugReports :: Maybe (Maybe String)-, packageConfigCategory :: Maybe String+, packageConfigCategory :: Maybe (List String) , packageConfigStability :: Maybe String , packageConfigAuthor :: Maybe (List String) , packageConfigMaintainer :: Maybe (Maybe (List String))@@ -1032,7 +1032,7 @@ , packageDescription :: Maybe String , packageHomepage :: Maybe String , packageBugReports :: Maybe String-, packageCategory :: Maybe String+, packageCategory :: [String] , packageStability :: Maybe String , packageAuthor :: [String] , packageMaintainer :: [String]@@ -1326,7 +1326,7 @@ , packageDescription = packageConfigDescription , packageHomepage = homepage , packageBugReports = bugReports- , packageCategory = packageConfigCategory+ , packageCategory = fromMaybeList packageConfigCategory , packageStability = packageConfigStability , packageAuthor = fromMaybeList packageConfigAuthor , packageMaintainer = fromMaybeList maintainer
src/Hpack/Render.hs view
@@ -118,24 +118,30 @@ , ("version", Just packageVersion) , ("synopsis", packageSynopsis) , ("description", (formatDescription packageCabalVersion headerFieldsAlignment <$> packageDescription))- , ("category", packageCategory)+ , formatList "category" packageCategory , ("stability", packageStability) , ("homepage", packageHomepage) , ("bug-reports", packageBugReports)- , ("author", formatList packageAuthor)- , ("maintainer", formatList packageMaintainer)- , ("copyright", formatList packageCopyright)+ , formatList "author" packageAuthor+ , formatList "maintainer" packageMaintainer+ , formatList "copyright" packageCopyright , ("license", packageLicense) , case packageLicenseFile of [file] -> ("license-file", Just file)- files -> ("license-files", formatList files)+ files -> formatList "license-files" files , ("build-type", Just (show packageBuildType)) ] - formatList :: [String] -> Maybe String- formatList xs = guard (not $ null xs) >> (Just $ intercalate separator xs)+ formatList :: String -> [String] -> (String, Maybe String)+ formatList field = (,) field . formatValues where- separator = let Alignment n = headerFieldsAlignment in ",\n" ++ replicate n ' '+ formatValues :: [String] -> Maybe String+ formatValues values = guard (not $ null values) >> (Just $ intercalate separator values)+ where+ separator :: String+ separator = ",\n" ++ replicate n ' '+ where+ Alignment n = max headerFieldsAlignment (Alignment $ length field + 2) sortStanzaFields :: [(String, [String])] -> [Element] -> [Element] sortStanzaFields sectionsFieldOrder = go
src/Hpack/Render/Dsl.hs view
@@ -46,7 +46,7 @@ deriving (Eq, Show, Num, Enum) newtype Alignment = Alignment Int- deriving (Eq, Show, Num)+ deriving (Eq, Ord, Show, Num) data RenderSettings = RenderSettings { renderSettingsIndentation :: Int
test/EndToEndSpec.hs view
@@ -103,6 +103,24 @@ baz |]) { packageCabalVersion = "3.0" } + describe "category" $ do+ it "accepts a single category" $ do+ [i|+ category: Testing+ |] `shouldRenderTo` package [i|+ category: Testing+ |]++ it "accepts a list of categories" $ do+ [i|+ category:+ - Development+ - Testing+ |] `shouldRenderTo` package [i|+ category: Development,+ Testing+ |]+ describe "handling of Paths_ module" $ do it "adds Paths_ to other-modules" $ do [i|
test/Hpack/ConfigSpec.hs view
@@ -225,7 +225,7 @@ withPackageConfig_ [i| category: Data |]- (`shouldBe` package {packageCategory = Just "Data"})+ (`shouldBe` package {packageCategory = ["Data"]}) it "accepts author" $ do withPackageConfig_ [i|