Commit 283030c0 authored by quasicomputational's avatar quasicomputational

Re-target glob features to 2.4, rather than 3.0.

parent 9796ec68
......@@ -122,8 +122,8 @@ extra-source-files:
tests/ParserTests/regressions/nothing-unicode.format
tests/ParserTests/regressions/pre-1.6-glob.cabal
tests/ParserTests/regressions/pre-1.6-glob.check
tests/ParserTests/regressions/pre-3.0-globstar.cabal
tests/ParserTests/regressions/pre-3.0-globstar.check
tests/ParserTests/regressions/pre-2.4-globstar.cabal
tests/ParserTests/regressions/pre-2.4-globstar.check
tests/ParserTests/regressions/shake.cabal
tests/ParserTests/regressions/shake.expr
tests/ParserTests/regressions/shake.format
......
......@@ -14,7 +14,7 @@
([#5226](https://github.com/haskell/cabal/issues/5226)).
* Allow `**` wildcards in `data-files`, `extra-source-files` and
`extra-doc-files`. These allow a limited form of recursive
matching, and require `cabal-version: 3.0`.
matching, and require `cabal-version: 2.4`.
Wildcard syntax errors (misplaced `*`, etc) are also now detected
by `cabal check`.
......@@ -38,7 +38,7 @@
`cxx-options`, `cpp-options` are not deduplicated anymore
([#4449](https://github.com/haskell/cabal/issues/4449)).
* Deprecated `cabal hscolour` in favour of `cabal haddock --hyperlink-source` ([#5236](https://github.com/haskell/cabal/pull/5236/)).
* With `cabal-version: 3.0`, when matching a wildcard, the
* With `cabal-version: 2.4`, when matching a wildcard, the
requirement for the full extension to match exactly has been
loosened. Instead, if the wildcard's extension is a suffix of the
file's extension, the file will be selected. For example,
......
......@@ -2158,9 +2158,9 @@ checkTarPath path
checkPackageMissingFiles :: PackageDescription -> FilePath -> NoCallStackIO [PackageCheck]
checkPackageMissingFiles = checkGlobMultiDot
-- | Before Cabal 3.0, the extensions of globs had to match the file
-- exactly. This has been relaxed in 3.0 to allow matching only the
-- suffix. This warning detects when pre-3.0 package descriptions are
-- | Before Cabal 2.4, the extensions of globs had to match the file
-- exactly. This has been relaxed in 2.4 to allow matching only the
-- suffix. This warning detects when pre-2.4 package descriptions are
-- omitting files purely because of the stricter check.
checkGlobMultiDot :: PackageDescription
-> FilePath
......@@ -2174,7 +2174,7 @@ checkGlobMultiDot pkg root =
"In '" ++ field ++ "': the pattern '" ++ glob ++ "' does not"
++ " match the file '" ++ file ++ "' because the extensions do not"
++ " exactly match (e.g., foo.en.html does not exactly match *.html)."
++ " To enable looser suffix-only matching, set 'cabal-version: 3.0' or higher."
++ " To enable looser suffix-only matching, set 'cabal-version: 2.4' or higher."
| GlobWarnMultiDot file <- results
]
where
......
......@@ -95,7 +95,7 @@ explainGlobSyntaxError _ EmptyGlob =
"invalid file glob. A glob cannot be the empty string."
explainGlobSyntaxError filepath VersionDoesNotSupportGlobStar =
"invalid file glob '" ++ filepath
++ "'. Using the double-star syntax requires 'cabal-version: 3.0'"
++ "'. Using the double-star syntax requires 'cabal-version: 2.4'"
++ " or greater. Alternatively, for compatibility with earlier Cabal"
++ " versions, list the included directories explicitly."
explainGlobSyntaxError filepath VersionDoesNotSupportGlob =
......@@ -185,12 +185,12 @@ parseFileGlob version filepath = case reverse (splitDirectories filepath) of
foldM addStem (GlobFinal pat) segments
where
allowGlob = version >= mkVersion [1,6]
allowGlobStar = version >= mkVersion [3,0]
allowGlobStar = version >= mkVersion [2,4]
addStem pat seg
| '*' `elem` seg = Left StarInDirectory
| otherwise = Right (GlobStem seg pat)
multidot
| version >= mkVersion [3,0] = MultiDotEnabled
| version >= mkVersion [2,4] = MultiDotEnabled
| otherwise = MultiDotDisabled
matchFileGlob :: Verbosity -> Version -> FilePath -> IO [GlobResult FilePath]
......
......@@ -994,10 +994,10 @@ describe the package as a whole:
used with an extension, so ``data-files: data/*`` is not
allowed.
- Prior to Cabal 3.0, when matching a wildcard plus extension, a
- Prior to Cabal 2.4, when matching a wildcard plus extension, a
file's full extension must match exactly, so ``*.gz`` matches
``foo.gz`` but not ``foo.tar.gz``. This restriction has been
lifted when ``cabal-version: 3.0`` or greater so that ``*.gz``
lifted when ``cabal-version: 2.4`` or greater so that ``*.gz``
does match ``foo.tar.gz``
- ``*`` wildcards will not match if the file name is empty (e.g.,
......@@ -1023,7 +1023,7 @@ describe the package as a whole:
behaviour, put the files that wildcards will match against in
their own folder.
``**`` wildcards are available starting in Cabal 3.0.
``**`` wildcards are available starting in Cabal 2.4.
.. pkg-field:: data-dir: directory
......
......@@ -31,7 +31,7 @@ checkTests = testGroup "regressions"
, checkTest "MiniAgda.cabal"
, checkTest "extensions-paths-5054.cabal"
, checkTest "pre-1.6-glob.cabal"
, checkTest "pre-3.0-globstar.cabal"
, checkTest "pre-2.4-globstar.cabal"
, checkTest "bad-glob-syntax.cabal"
, checkTest "cc-options-with-optimization.cabal"
, checkTest "cxx-options-with-optimization.cabal"
......
In the 'data-files' field: invalid file glob 'foo/**/*.dat'. Using the double-star syntax requires 'cabal-version: 3.0' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
In the 'extra-source-files' field: invalid file glob 'foo/**/*.hs'. Using the double-star syntax requires 'cabal-version: 3.0' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
In the 'extra-doc-files' field: invalid file glob 'foo/**/*.html'. Using the double-star syntax requires 'cabal-version: 3.0' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
In the 'data-files' field: invalid file glob 'foo/**/*.dat'. Using the double-star syntax requires 'cabal-version: 2.4' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
In the 'extra-source-files' field: invalid file glob 'foo/**/*.hs'. Using the double-star syntax requires 'cabal-version: 2.4' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
In the 'extra-doc-files' field: invalid file glob 'foo/**/*.html'. Using the double-star syntax requires 'cabal-version: 2.4' or greater. Alternatively, for compatibility with earlier Cabal versions, list the included directories explicitly.
......@@ -132,12 +132,12 @@ globstarTests =
testMatches "foo/**/*.html" [GlobMatch "foo/a.html", GlobMatch "foo/b.html", GlobMatch "foo/bar/a.html", GlobMatch "foo/bar/b.html"]
]
where
testFailParse = testFailParseVersion (mkVersion [3,0])
testMatches = testMatchesVersion (mkVersion [3,0])
testFailParse = testFailParseVersion (mkVersion [2,4])
testMatches = testMatchesVersion (mkVersion [2,4])
multiDotTests :: [TestTree]
multiDotTests =
[ testCase "pre-3.0 single extension not matching multiple" $
[ testCase "pre-2.4 single extension not matching multiple" $
testMatchesVersion (mkVersion [2,2]) "foo/*.gz" [GlobWarnMultiDot "foo/a.html.gz", GlobWarnMultiDot "foo/a.tex.gz", GlobWarnMultiDot "foo/b.html.gz", GlobMatch "foo/x.gz"]
, testCase "doesn't match literal" $
testMatches "foo/a.tex" [GlobMatch "foo/a.tex"]
......@@ -147,14 +147,14 @@ multiDotTests =
testMatches "foo/**/*.gz" [GlobMatch "foo/a.html.gz", GlobMatch "foo/a.tex.gz", GlobMatch "foo/b.html.gz", GlobMatch "foo/x.gz", GlobMatch "foo/bar/a.html.gz", GlobMatch "foo/bar/a.tex.gz", GlobMatch "foo/bar/b.html.gz"]
]
where
testMatches = testMatchesVersion (mkVersion [3,0])
testMatches = testMatchesVersion (mkVersion [2,4])
tests :: [TestTree]
tests =
[ testGroup "pre-3.0 compatibility" $
[ testGroup "pre-2.4 compatibility" $
compatibilityTests (mkVersion [2,2])
, testGroup "post-3.0 compatibility" $
compatibilityTests (mkVersion [3,0])
, testGroup "post-2.4 compatibility" $
compatibilityTests (mkVersion [2,4])
, testGroup "globstar" globstarTests
, testCase "pre-1.6 rejects globbing" $
testFailParseVersion (mkVersion [1,4]) "foo/*.bar" VersionDoesNotSupportGlob
......
# cabal check
Warning: These warnings may cause trouble when distributing the package:
Warning: In 'data-files': the pattern 'data/*.dat' does not match the file 'data/foo.bar.dat' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 3.0' or higher.
Warning: In 'extra-doc-files': the pattern 'doc/*.html' does not match the file 'doc/foo.en.html' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 3.0' or higher.
Warning: In 'extra-doc-files': the pattern 'doc/*.html' does not match the file 'doc/foo.fr.html' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 3.0' or higher.
Warning: In 'data-files': the pattern 'data/*.dat' does not match the file 'data/foo.bar.dat' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 2.4' or higher.
Warning: In 'extra-doc-files': the pattern 'doc/*.html' does not match the file 'doc/foo.en.html' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 2.4' or higher.
Warning: In 'extra-doc-files': the pattern 'doc/*.html' does not match the file 'doc/foo.fr.html' because the extensions do not exactly match (e.g., foo.en.html does not exactly match *.html). To enable looser suffix-only matching, set 'cabal-version: 2.4' or higher.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment