Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions assets/issues/issue-525/from.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: a-type-of-file
allowed:
- digest: sha256:1111111111111111111111111111111111111111111111111111111111111111
image: name/container
registry: ghcr.io
tag: 1.2.3
field:
- test
- digest: sha256:22222222222222222222222222222222222222222222222222222222222222222
image: yes/i-am-an-image
registry: docker.io
tag: 1.2.3-test_with.symbols
- digest: sha256:33333333333333333333333333333333333333333333333333333333333333333
image: another/image
registry: gcr.io
tag: 3.2.1
- digest: sha256:4444444444444444444444444444444444444444444444444444444444444444
image: oh-look/another-image
registry: quay.io
tag: 3.1.2-test-with-dashes
- digest: sha256:5555555555555555555555555555555555555555555555555555555555555555
image: you-would-not/guess
registry: docker.io
tag: 1.3.2
- digest: sha256:6666666666666666666666666666666666666666666666666666666666666666
image: no-way/this-is-an-image
registry: guess.io
tag: latest
32 changes: 32 additions & 0 deletions assets/issues/issue-525/to.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: a-type-of-file
allowed:
- digest: sha256:1111111111111111111111111111111111111111111111111111111111111111
image: name/container
registry: ghcr.io
tag: 1.2.4
field:
- test
- digest: sha256:22222222222222222222222222222222222222222222222222222222222222222
image: yes/i-am-an-image
registry: docker.io
tag: 1.2.4-test_with.symbols
- digest: sha256:33333333333333333333333333333333333333333333333333333333333333333
image: another/image
registry: gcr.io
tag: 3.2.1
- digest: sha256:4444444444444444444444444444444444444444444444444444444444444444
image: oh-look/another-flaky
registry: quay.io
tag: 3.1.2-test-with-dashes
- digest: sha256:0000000000000000000000000000000000000000000000000000000000000000
image: you-would-not/guess
registry: docker.io
tag: 1.3.2
- digest: sha256:6666666666666666666666666666666666666666666666666666666666666666
image: no-way/this-is-an-image
registry: guess.io
tag: latest
- digest: sha256:6666666666666666666666666666666666666666666666666666666666666666
image: additional/image
registry: new.io
tag: 9.8.7
2 changes: 1 addition & 1 deletion assets/testbed/expected-dyff-gopatch.github
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@
- - name: one
- - name: two
! + one list entry added:
+ - name: three
+ - name: three

2 changes: 1 addition & 1 deletion assets/testbed/expected-dyff-spruce.github
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@
- - name: one
- - name: two
! + one list entry added:
+ - name: three
+ - name: three

11 changes: 9 additions & 2 deletions pkg/dyff/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/gonvenience/idem"
"github.com/gonvenience/text"
"github.com/gonvenience/ytbx"

"github.com/mitchellh/hashstructure"
yamlv3 "gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -946,7 +945,15 @@ func (compare *compare) getNonStandardIdentifierFromNamedLists(listA, listB *yam
counterA := createKeyCountMap(listA)
counterB := createKeyCountMap(listB)

for keyA, countA := range counterA {
// Sort the keys to ensure deterministic order
keysA := make([]string, 0, len(counterA))
for keyA := range counterA {
keysA = append(keysA, keyA)
}
sort.Strings(keysA)

for _, keyA := range keysA {
countA := counterA[keyA]
if countB, ok := counterB[keyA]; ok {
if countA == listALength && countB == listBLength && countA > compare.settings.NonStandardIdentifierGuessCountThreshold {
return &singleField{keyA}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dyff/output_human.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (report *HumanReport) generateHumanDetailOutputAddition(detail Detail) (str
return "", err
}

report.writeTextBlocks(&output, 2, yamlOutput)
report.writeTextBlocks(&output, report.Indent, yamlOutput)

return output.String(), nil
}
Expand Down
Loading