Skip to content

Commit ab33100

Browse files
authored
Merge pull request ipfs/go-merkledag#70 from ipfs/web3-bot/sync
sync: update CI config files This commit was moved from ipfs/go-merkledag@151483a
2 parents bd9c144 + d229bf7 commit ab33100

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

ipld/merkledag/dagutils/diff.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,28 @@ type Conflict struct {
176176
// Changes involved (which share the same path).
177177
func MergeDiffs(a, b []*Change) ([]*Change, []Conflict) {
178178
paths := make(map[string]*Change)
179-
for _, c := range a {
179+
for _, c := range b {
180180
paths[c.Path] = c
181181
}
182182

183183
var changes []*Change
184184
var conflicts []Conflict
185185

186-
for _, changeB := range b {
187-
if changeA, ok := paths[changeB.Path]; ok {
186+
// NOTE: we avoid iterating over maps here to ensure iteration order is determistic. We
187+
// include changes from a first, then b.
188+
for _, changeA := range a {
189+
if changeB, ok := paths[changeA.Path]; ok {
188190
conflicts = append(conflicts, Conflict{changeA, changeB})
189191
} else {
190-
changes = append(changes, changeB)
192+
changes = append(changes, changeA)
191193
}
192-
delete(paths, changeB.Path)
194+
delete(paths, changeA.Path)
193195
}
194196

195-
for _, c := range paths {
196-
changes = append(changes, c)
197+
for _, c := range b {
198+
if _, ok := paths[c.Path]; ok {
199+
changes = append(changes, c)
200+
}
197201
}
198202

199203
return changes, conflicts

ipld/merkledag/dagutils/diff_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ func TestMergeDiffs(t *testing.T) {
3333
}
3434

3535
expect := []*Change{
36-
changesB[1],
3736
changesA[0],
3837
changesA[2],
38+
changesB[1],
3939
}
4040

4141
for i, change := range changes {

ipld/merkledag/dagutils/diffenum_test.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -46,61 +46,61 @@ func mkGraph(desc map[string]ndesc) map[string]ipld.Node {
4646
}
4747

4848
var tg1 = map[string]ndesc{
49-
"a1": ndesc{
49+
"a1": {
5050
"foo": "b",
5151
},
52-
"b": ndesc{},
53-
"a2": ndesc{
52+
"b": {},
53+
"a2": {
5454
"foo": "b",
5555
"bar": "c",
5656
},
57-
"c": ndesc{},
57+
"c": {},
5858
}
5959

6060
var tg2 = map[string]ndesc{
61-
"a1": ndesc{
61+
"a1": {
6262
"foo": "b",
6363
},
64-
"b": ndesc{},
65-
"a2": ndesc{
64+
"b": {},
65+
"a2": {
6666
"foo": "b",
6767
"bar": "c",
6868
},
69-
"c": ndesc{"baz": "d"},
70-
"d": ndesc{},
69+
"c": {"baz": "d"},
70+
"d": {},
7171
}
7272

7373
var tg3 = map[string]ndesc{
74-
"a1": ndesc{
74+
"a1": {
7575
"foo": "b",
7676
"bar": "c",
7777
},
78-
"b": ndesc{},
79-
"a2": ndesc{
78+
"b": {},
79+
"a2": {
8080
"foo": "b",
8181
"bar": "d",
8282
},
83-
"c": ndesc{},
84-
"d": ndesc{},
83+
"c": {},
84+
"d": {},
8585
}
8686

8787
var tg4 = map[string]ndesc{
88-
"a1": ndesc{
88+
"a1": {
8989
"key1": "b",
9090
"key2": "c",
9191
},
92-
"a2": ndesc{
92+
"a2": {
9393
"key1": "b",
9494
"key2": "d",
9595
},
9696
}
9797

9898
var tg5 = map[string]ndesc{
99-
"a1": ndesc{
99+
"a1": {
100100
"key1": "a",
101101
"key2": "b",
102102
},
103-
"a2": ndesc{
103+
"a2": {
104104
"key1": "c",
105105
"key2": "d",
106106
},

ipld/merkledag/merkledag_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ func TestFetchGraphWithDepthLimit(t *testing.T) {
350350
}
351351

352352
tests := []testcase{
353-
testcase{1, 4},
354-
testcase{0, 1},
355-
testcase{-1, 6},
356-
testcase{2, 6},
357-
testcase{3, 6},
353+
{1, 4},
354+
{0, 1},
355+
{-1, 6},
356+
{2, 6},
357+
{3, 6},
358358
}
359359

360360
testF := func(t *testing.T, tc testcase) {

0 commit comments

Comments
 (0)