Skip to content

Commit

Permalink
engine: switched to multilinediff package (#47)
Browse files Browse the repository at this point in the history
Improve diff readability by switching to the multilinediff package which
has a much more readable two-column diff setup. Eventually this package
will be improved to have coloured output, which this tool can benefit
from when it's ready.
  • Loading branch information
braydonk committed Sep 19, 2022
1 parent d9d4189 commit f3eff05
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 176 deletions.
6 changes: 3 additions & 3 deletions engine/engine.go
Expand Up @@ -18,8 +18,8 @@ import (
"fmt"
"os"

"github.com/RageCage64/multilinediff"
"github.com/google/yamlfmt"
"github.com/google/yamlfmt/internal/diff"
"github.com/google/yamlfmt/internal/paths"
)

Expand Down Expand Up @@ -91,7 +91,7 @@ func (e *Engine) LintFile(path string) error {
if err != nil {
return err
}
diffContent := diff.MultilineStringDiff(string(yamlBytes), string(formatted))
diffContent := multilinediff.MultilineDiff(string(yamlBytes), string(formatted), "\n")
if diffContent != "" {
return fmt.Errorf(diffContent)
}
Expand Down Expand Up @@ -130,6 +130,6 @@ func (e *Engine) DryRunFile(path string) (string, error) {
if err != nil {
return "", err
}
diffContent := diff.MultilineStringDiff(string(yamlBytes), string(formatted))
diffContent := multilinediff.MultilineDiff(string(yamlBytes), string(formatted), "\n")
return diffContent, nil
}
4 changes: 3 additions & 1 deletion go.mod
Expand Up @@ -4,8 +4,10 @@ go 1.19

require (
github.com/RageCage64/go-utf8-codepoint-converter v0.1.0
github.com/RageCage64/multilinediff v0.1.0
github.com/bmatcuk/doublestar/v4 v4.2.0
github.com/google/go-cmp v0.5.8
github.com/mitchellh/mapstructure v1.5.0
gopkg.in/yaml.v3 v3.0.1
)

require github.com/google/go-cmp v0.5.9 // indirect
6 changes: 4 additions & 2 deletions go.sum
@@ -1,9 +1,11 @@
github.com/RageCage64/go-utf8-codepoint-converter v0.1.0 h1:6GreQRSQApXW1sgeFXMBLDdxSC6DCzu4lKBS/LEyrSA=
github.com/RageCage64/go-utf8-codepoint-converter v0.1.0/go.mod h1:asNWDxR7n0QIQyZNYTlpNk6Dg7GkUnxtCXho987uen8=
github.com/RageCage64/multilinediff v0.1.0 h1:P9Iht5Vj4SHSmTJhQPJnySzTlX/cpL99kN3RJxejipQ=
github.com/RageCage64/multilinediff v0.1.0/go.mod h1:pKr+KLgP0gvRzA+yv0/IUaYQuBYN1ucWysvsL58aMP0=
github.com/bmatcuk/doublestar/v4 v4.2.0 h1:Qu+u9wR3Vd89LnlLMHvnZ5coJMWKQamqdz9/p5GNthA=
github.com/bmatcuk/doublestar/v4 v4.2.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
34 changes: 0 additions & 34 deletions internal/diff/diff.go

This file was deleted.

78 changes: 0 additions & 78 deletions internal/diff/diff_test.go

This file was deleted.

58 changes: 0 additions & 58 deletions internal/diff/reporter.go

This file was deleted.

0 comments on commit f3eff05

Please sign in to comment.