fix diff/ ordering of cased packages with consistent use of toCaseFold

fixes #315

Thank you to @alaendle and @andreasabel
This commit is contained in:
Jens Petersen 2023-06-25 15:55:36 +08:00
parent 19de58f2ab
commit b3e7fcbfe1

View File

@ -75,14 +75,14 @@ snapshotDiff
-> [(PackageNameP, VersionP)] -> [(PackageNameP, VersionP)]
-> SnapshotDiff -> SnapshotDiff
snapshotDiff as0 bs0 = snapshotDiff as0 bs0 =
SnapshotDiff $ map (second VersionChange) $ go (sortEm as0) (sortEm bs0) SnapshotDiff $ map (second VersionChange) $ go (sortOn cmp as0) (sortOn cmp bs0)
where where
sortEm = sortOn (toCaseFold . textDisplay . fst) cmp = toCaseFold . textDisplay . fst
go as [] = map (second This) as go as [] = map (second This) as
go [] bs = map (second That) bs go [] bs = map (second That) bs
go (a:as) (b:bs) = go (a:as) (b:bs) =
case compare (fst a) (fst b) of case (compare `on` cmp) a b of
EQ EQ
| snd a == snd b -> go as bs | snd a == snd b -> go as bs
| otherwise -> (fst a, These (snd a) (snd b)) : go as bs | otherwise -> (fst a, These (snd a) (snd b)) : go as bs