Skip to content

Commit b842593

Browse files
Copilotneongreen
andcommitted
beads-merge: Use go-cmp library for deep equality comparison
Co-authored-by: neongreen <1523306+neongreen@users.noreply.github.com>
1 parent b8e30f8 commit b842593

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

beads-merge/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/neongreen/mono/beads-merge
22

33
go 1.24.7
4+
5+
require github.com/google/go-cmp v0.7.0 // indirect

beads-merge/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=

beads-merge/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"fmt"
77
"os"
88
"time"
9+
10+
"github.com/google/go-cmp/cmp"
911
)
1012

1113
// Issue represents a beads issue with all possible fields
@@ -361,9 +363,10 @@ func hasConflict(base, left, right, merged Issue) bool {
361363
}
362364

363365
func issuesEqual(a, b Issue) bool {
364-
aJSON, _ := json.Marshal(a)
365-
bJSON, _ := json.Marshal(b)
366-
return string(aJSON) == string(bJSON)
366+
// Use go-cmp for deep equality comparison, ignoring RawLine field
367+
return cmp.Equal(a, b, cmp.FilterPath(func(p cmp.Path) bool {
368+
return p.String() == "RawLine"
369+
}, cmp.Ignore()))
367370
}
368371

369372
func makeConflict(left, right string) string {

0 commit comments

Comments
 (0)