mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-25 03:09:00 -06:00
Don't quote struct field names in diff (#2177)
This commit is contained in:
@@ -146,10 +146,10 @@ func diffStructs(w io.Writer, p types.Path, v1, v2 types.Struct) {
|
||||
switch change.ChangeType {
|
||||
case types.DiffChangeAdded:
|
||||
wroteHeader = writeHeader(w, wroteHeader, p)
|
||||
line(w, ADD, change.V, v2.Get(fn))
|
||||
field(w, ADD, change.V, v2.Get(fn))
|
||||
case types.DiffChangeRemoved:
|
||||
wroteHeader = writeHeader(w, wroteHeader, p)
|
||||
line(w, DEL, change.V, v1.Get(fn))
|
||||
field(w, DEL, change.V, v1.Get(fn))
|
||||
case types.DiffChangeModified:
|
||||
f1 := v1.Get(fn)
|
||||
f2 := v2.Get(fn)
|
||||
@@ -157,8 +157,8 @@ func diffStructs(w io.Writer, p types.Path, v1, v2 types.Struct) {
|
||||
diff(w, p.AddField(fn), types.String(fn), f1, f2)
|
||||
} else {
|
||||
wroteHeader = writeHeader(w, wroteHeader, p)
|
||||
line(w, DEL, change.V, f1)
|
||||
line(w, ADD, change.V, f2)
|
||||
field(w, DEL, change.V, f1)
|
||||
field(w, ADD, change.V, f2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,6 +203,14 @@ func line(w io.Writer, op int, key, val types.Value) {
|
||||
write(w, []byte("\n"))
|
||||
}
|
||||
|
||||
func field(w io.Writer, op int, name, val types.Value) {
|
||||
pw := newPrefixWriter(w, op)
|
||||
write(pw, []byte(name.(types.String)))
|
||||
write(w, []byte(": "))
|
||||
writeEncodedValue(pw, val)
|
||||
write(w, []byte("\n"))
|
||||
}
|
||||
|
||||
func writeHeader(w io.Writer, wroteHeader bool, p types.Path) bool {
|
||||
if !wroteHeader {
|
||||
if len(p) == 0 {
|
||||
|
||||
@@ -141,8 +141,8 @@ func TestNomsStructDiff(t *testing.T) {
|
||||
+ "four": "four-diff"
|
||||
}
|
||||
["three"] {
|
||||
- "field3": "field3-data"
|
||||
+ "field3": "field3-data-diff"
|
||||
- field3: "field3-data"
|
||||
+ field3: "field3-data-diff"
|
||||
`
|
||||
|
||||
fieldData := []interface{}{
|
||||
|
||||
Reference in New Issue
Block a user