preserving ordering in arrays.

This commit is contained in:
2025-01-10 19:38:43 +01:00
parent b06f6af708
commit c21adb9a35
3 changed files with 18 additions and 7 deletions
+10 -3
View File
@@ -45,7 +45,8 @@ func subtract(yaml2 yaml.MapSlice, yaml1 yaml.MapSlice) yaml.MapSlice {
v1set[strval(v)] = true
}
s := make([]any, 0)
for k2, _ := range v2set {
for _, v2value := range v2.([]any) {
k2 := strval(v2value)
if v1set[k2] {
if VERBOSITY == 2 {
s = append(s, "<UNMODIFIED>")
@@ -77,8 +78,14 @@ func diff(cmd *cobra.Command, args []string) error {
file1 := args[0]
file2 := args[1]
yaml1 := parse(read(file1))
yaml2 := parse(read(file2))
yaml1, err := parse(read(file1))
if err != nil {
panic(fmt.Errorf("%s: %w", file1, err))
}
yaml2, err := parse(read(file2))
if err != nil {
panic(fmt.Errorf("%s: %w", file2, err))
}
diff1 := subtract(yaml2, yaml1)
diff2 := make(yaml.MapSlice, 0)