Skip to content

Commit

Permalink
fix: updated output param of core.Diff to `*map[string]*datasetDiffer…
Browse files Browse the repository at this point in the history
….SubDiff`
  • Loading branch information
Thomas Osterbind committed Feb 2, 2018
1 parent 1d30107 commit 8e1aa39
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/qri-io/qri/p2p"
"github.com/qri-io/qri/repo"
"github.com/qri-io/varName"
diff "github.com/yudai/gojsondiff"
)

// DatasetRequests encapsulates business logic for this node's
Expand Down Expand Up @@ -731,10 +730,10 @@ type DiffParams struct {
}

// Diff computes the diff of two datasets
func (r *DatasetRequests) Diff(p *DiffParams, diffs *map[string]diff.Diff) (err error) {
diffMap := map[string]diff.Diff{}
func (r *DatasetRequests) Diff(p *DiffParams, diffs *map[string]*datasetDiffer.SubDiff) (err error) {
diffMap := make(map[string]*datasetDiffer.SubDiff)
if p.DiffAll {
diffMap, err := datasetDiffer.DiffDatasets(p.DsLeft, p.DsRight)
diffMap, err := datasetDiffer.DiffDatasets(p.DsLeft, p.DsRight, nil)
if err != nil {
return fmt.Errorf("error diffing datasets: %s", err.Error())
}
Expand All @@ -753,7 +752,7 @@ func (r *DatasetRequests) Diff(p *DiffParams, diffs *map[string]diff.Diff) (err
if p.DsLeft.Structure != nil && p.DsRight.Structure != nil {
structureDiffs, err := datasetDiffer.DiffStructure(p.DsLeft.Structure, p.DsRight.Structure)
if err != nil {
return fmt.Errorf("error diffing structure: %s", err.Error())
return fmt.Errorf("error diffing %s: %s", k, err.Error())
}
diffMap[k] = structureDiffs
}
Expand All @@ -762,32 +761,31 @@ func (r *DatasetRequests) Diff(p *DiffParams, diffs *map[string]diff.Diff) (err
if p.DsLeft.DataPath != "" && p.DsRight.DataPath != "" {
dataDiffs, err := datasetDiffer.DiffData(p.DsLeft, p.DsRight)
if err != nil {
return fmt.Errorf("error diffing data: %s", err.Error())
return fmt.Errorf("error diffing %s: %s", k, err.Error())
}

diffMap[k] = dataDiffs
}
case "transform":
if p.DsLeft.Transform != nil && p.DsRight.Transform != nil {
transformDiffs, err := datasetDiffer.DiffTransform(p.DsLeft.Transform, p.DsRight.Transform)
if err != nil {
return fmt.Errorf("error diffing transform: %s", err.Error())
return fmt.Errorf("error diffing %s: %s", k, err.Error())
}
diffMap[k] = transformDiffs
}
case "meta":
if p.DsLeft.Meta != nil && p.DsRight.Meta != nil {
metaDiffs, err := datasetDiffer.DiffMeta(p.DsLeft.Meta, p.DsRight.Meta)
if err != nil {
return fmt.Errorf("error diffing meta: %s", err.Error())
return fmt.Errorf("error diffing %s: %s", k, err.Error())
}
diffMap[k] = metaDiffs
}
case "visConfig":
if p.DsLeft.VisConfig != nil && p.DsRight.VisConfig != nil {
visConfigDiffs, err := datasetDiffer.DiffVisConfig(p.DsLeft.VisConfig, p.DsRight.VisConfig)
if err != nil {
return fmt.Errorf("error diffing visConfig: %s", err.Error())
return fmt.Errorf("error diffing %s: %s", k, err.Error())
}
diffMap[k] = visConfigDiffs
}
Expand Down Expand Up @@ -837,7 +835,7 @@ func (r *DatasetRequests) Diff(p *DiffParams, diffs *map[string]diff.Diff) (err
if err != nil {
return fmt.Errorf("error marshaling json: %s", err.Error())
}
dataDiffs, err := datasetDiffer.DiffJSON(dataBytes1, dataBytes2)
dataDiffs, err := datasetDiffer.DiffJSON(dataBytes1, dataBytes2, "data")
if err != nil {
return fmt.Errorf("error comparing structured data: %s", err.Error())
}
Expand Down

0 comments on commit 8e1aa39

Please sign in to comment.