Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1810: Unicode-normalized pkg name comparison #2397

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Stack/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import qualified System.Directory as D
import qualified System.FilePath as FP
import System.Process.Read

import qualified Data.Text.Normalize as T ( normalize , NormalizationMode(NFC) )

data ConstraintType = Constraint | Preference deriving (Eq)
type ConstraintSpec = Map PackageName (Version, Map FlagName Bool)
Expand Down Expand Up @@ -560,8 +561,9 @@ cabalPackagesCheck cabalfps noPkgMsg dupErrMsg = do
-- Just the latter check is enough to cover both the cases

let packages = zip cabalfps gpds
normalizeString = T.unpack . T.normalize T.NFC . T.pack
getNameMismatchPkg (fp, gpd)
| (show . gpdPackageName) gpd /= (FP.takeBaseName . toFilePath) fp
| (normalizeString . show . gpdPackageName) gpd /= (normalizeString . FP.takeBaseName . toFilePath) fp
= Just fp
| otherwise = Nothing
nameMismatchPkgs = mapMaybe getNameMismatchPkg packages
Expand Down
1 change: 1 addition & 0 deletions stack-7.8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extra-deps:
- th-orphans-0.13.1
- base-orphans-0.5.4
- tar-0.5.0.3
- unicode-transforms-0.1.0.1
flags:
time-locale-compat:
old-locale: false
1 change: 1 addition & 0 deletions stack-8.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ extra-deps:
- http-client-0.5.0
- http-conduit-2.2.0
- http-client-tls-0.3.0
- unicode-transforms-0.1.0.1
1 change: 1 addition & 0 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ library
, tls >= 1.3.8
, transformers >= 0.3.0.0 && < 0.6
, transformers-base >= 0.4.4
, unicode-transforms >= 0.1 && <0.2
, unix-compat
, unordered-containers >= 0.2.5.1
, vector >= 0.10.12.3 && < 0.12
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ extra-deps:
- http-client-tls-0.3.0
- http-conduit-2.2.0
- path-0.5.8
- unicode-transforms-0.1.0.1
3 changes: 0 additions & 3 deletions test/integration/lib/StackTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ exeExt = if isWindows then ".exe" else ""
-- | Is the OS Windows?
isWindows = os == "mingw32"

-- | Is the OS Mac OS X?
isMacOSX = os == "darwin"

-- | To avoid problems with GHC version mismatch when a new LTS major
-- version is released, pass this argument to @stack@ when running in
-- a global context. The LTS major version here should match that of
Expand Down
3 changes: 1 addition & 2 deletions test/integration/tests/1336-1337-new-package-names/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import StackTest
import Control.Monad
import System.Directory
import System.FilePath

Expand All @@ -18,7 +17,7 @@ main =
stackErr ["new", "44444444444444"]
stackErr ["new", "abc-1"]
stackErr ["new", "444-ば日本-4本"]
unless isMacOSX $ stack ["new", "ば日本-4本"]
stack ["new", "ば日本-4本"]
stack ["new", "אבהץש"]
stack ["new", "ΔΘΩϬ"]
doesExist "./ΔΘΩϬ/stack.yaml"
Expand Down