mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
cli: refactor internal/diff
to use internal/errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6696 GitOrigin-RevId: e668b0acf73f9598489f07e25577be997b211c28
This commit is contained in:
parent
ec13a55fd5
commit
cd72240450
@ -14,12 +14,15 @@ import (
|
||||
|
||||
"github.com/gonvenience/ytbx"
|
||||
"github.com/homeport/dyff/pkg/dyff"
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
|
||||
)
|
||||
|
||||
func YamlDiff(fromFile, toFile ytbx.InputFile, writer io.Writer, fileName string) (int, error) {
|
||||
var op errors.Op = "diff.YamlDiff"
|
||||
report, err := dyff.CompareInputFiles(fromFile, toFile, dyff.IgnoreOrderChanges(true))
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf("error while getting diff: %w", err)
|
||||
return -1, errors.E(op, fmt.Errorf("error while getting diff: %w", err))
|
||||
}
|
||||
reportWriter := &dyff.HumanReport{
|
||||
Report: report,
|
||||
@ -32,7 +35,7 @@ func YamlDiff(fromFile, toFile ytbx.InputFile, writer io.Writer, fileName string
|
||||
fmt.Fprintf(writer, "%s\n", fileName)
|
||||
err = reportWriter.WriteReport(writer)
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf("error while printing diff: %w", err)
|
||||
return -1, errors.E(op, fmt.Errorf("error while printing diff: %w", err))
|
||||
}
|
||||
}
|
||||
return len(report.Diffs), nil
|
||||
|
Loading…
Reference in New Issue
Block a user