Skip to content

Commit

Permalink
Support Diff-1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Dec 21, 2024
1 parent a660dd3 commit 17fe1d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Support Diff-1.0

## v0.1.0

Initial release
2 changes: 1 addition & 1 deletion skeletest.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ library
, aeson-pretty
, ansi-terminal >= 0.4.0
, containers
, Diff >= 0.5
, Diff >= 1.0
, directory
, filepath
, ghc ^>= 9.6 || ^>= 9.8 || ^>= 9.10
Expand Down
7 changes: 4 additions & 3 deletions src/Skeletest/Internal/Utils/Diff.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ module Skeletest.Internal.Utils.Diff (
showLineDiff,
) where

import Data.Algorithm.DiffContext (getContextDiffNew, prettyContextDiff)
import Data.Algorithm.DiffContext (getContextDiff, prettyContextDiff)
import Data.Algorithm.DiffContext qualified as Diff
import Data.Text (Text)
import Data.Text qualified as Text
import Text.PrettyPrint qualified as PP

showLineDiff :: (Text, Text) -> (Text, Text) -> Text
showLineDiff (fromName, fromContent) (toName, toContent) =
Text.pack . PP.render $
prettyContextDiff (ppText fromName) (ppText toName) ppText $
getContextDiffNew (Just 5) (Text.lines fromContent) (Text.lines toContent)
prettyContextDiff (ppText fromName) (ppText toName) (ppText . Diff.unnumber) $
getContextDiff (Just 5) (Text.lines fromContent) (Text.lines toContent)
where
ppText = PP.text . Text.unpack

0 comments on commit 17fe1d3

Please sign in to comment.