Skip to content

Commit

Permalink
Fix a regression related to indentation sniffing (close sol#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Jul 16, 2018
1 parent 29b1fff commit e5171a6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Changes in 0.29.5
- Fix a regression related to indentation sniffing (close #310)

## Changes in 0.29.4
- Desugar ^>= when dependency is a string (see #309)
- Add support for Apache, MPL and ISC when inferring `license` (see #305)
Expand Down
6 changes: 3 additions & 3 deletions hpack.cabal
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cabal-version: >= 1.10

-- This file has been generated from package.yaml by hpack version 0.29.3.
-- This file has been generated from package.yaml by hpack version 0.29.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: b74ce72f59395f87ee42933fe1146d9349b94fbb3be741ef85998ea2d37af660
-- hash: c9c40490b86bd987b33ab63f10fd311c44b89e37d5a75d5af8cd25db72992e99

name: hpack
version: 0.29.4
version: 0.29.5
synopsis: An alternative format for Haskell packages
description: See README at <https://github.com/sol/hpack#readme>
category: Development
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hpack
version: 0.29.4
version: 0.29.5
synopsis: An alternative format for Haskell packages
description: See README at <https://github.com/sol/hpack#readme>
maintainer: Simon Hengel <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Hpack/Render/Hints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sniffFormattingHints (sanitize -> input) = FormattingHints {
}

sanitize :: [String] -> [String]
sanitize = filter (not . null) . map stripEnd
sanitize = filter (not . isPrefixOf "cabal-version:") . filter (not . null) . map stripEnd

stripEnd :: String -> String
stripEnd = reverse . dropWhile isSpace . reverse
Expand Down
6 changes: 3 additions & 3 deletions test/Hpack/Render/HintsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ spec = do
, "license:"
, "license-file: "
, "build-type: Simple"
, "cabal-version: >= 1.10"
]
extractFieldOrder input `shouldBe` [
"name"
, "version"
, "license"
, "license-file"
, "build-type"
, "cabal-version"
]

describe "extractSectionsFieldOrder" $ do
Expand Down Expand Up @@ -60,6 +58,9 @@ spec = do
it "removes trailing whitespace" $ do
sanitize ["foo ", "bar "] `shouldBe` ["foo", "bar"]

it "removes cabal-version" $ do
sanitize ["cabal-version: 2.2", "bar "] `shouldBe` ["bar"]

describe "unindent" $ do
it "unindents" $ do
let input = [
Expand All @@ -81,7 +82,6 @@ spec = do
, "license: MIT"
, "license-file: LICENSE"
, "build-type: Simple"
, "cabal-version: >= 1.10"
]
sniffAlignment input `shouldBe` Just 16

Expand Down

0 comments on commit e5171a6

Please sign in to comment.