Skip to content

Commit

Permalink
fix bug and cleanup diff
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Worm <tony@hofstadter.io>
  • Loading branch information
verdverm committed Dec 29, 2021
1 parent cbd7b2d commit a25ff92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/hofstadter-io/cuetils

go 1.17

replace cuelang.org/go => github.com/hofstadter-io/cue v0.4.0-hofpatch-1

require (
cuelang.org/go v0.4.0
github.com/hofstadter-io/hof v0.5.17
Expand Down Expand Up @@ -62,5 +64,3 @@ require (
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
moul.io/http2curl v1.0.0 // indirect
)

replace cuelang.org/go => github.com/hofstadter-io/cue v0.4.0-hofpatch-1
12 changes: 11 additions & 1 deletion structural/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ func diffStruct(orig, next cue.Value, opts *flags.RootPflagpole) (cue.Value, boo
result = result.FillPath(cue.ParsePath("\"+\""), add)
}

// checks to see if nothing changed
i := 0
iter, _ = result.Fields()
for iter.Next() {
i++
}
if i == 0 {
return result, false
}

return result, true
}

Expand All @@ -91,7 +101,7 @@ func diffList(orig, next cue.Value, opts *flags.RootPflagpole) (cue.Value, bool)

result := []cue.Value{}
for oi.Next() && ni.Next() {
v, ok := pickValue(oi.Value(), ni.Value(), opts)
v, ok := diffValue(oi.Value(), ni.Value(), opts)
if ok {
result = append(result, v)
}
Expand Down
2 changes: 0 additions & 2 deletions structural/pick.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ func pickList(pick, from cue.Value, opts *flags.RootPflagpole) (cue.Value, bool)
}

return ctx.NewList(result...), true

return pick, false
}

func pickLeaf(pick, from cue.Value, opts *flags.RootPflagpole) (cue.Value, bool) {
Expand Down

0 comments on commit a25ff92

Please sign in to comment.