homeport / dyff

/ˈdʏf/ - diff tool for YAML files, and sometimes JSON
MIT License
1.33k stars 66 forks source link

BUG: Change identification - order changed #376

Open YashPatil0706 opened 4 months ago

YashPatil0706 commented 4 months ago

Dyff has a bug where it doesn't identify the value changed, instead it shows an order change

app1.yaml:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: a
  annotations:
    a: "2"

app2.yaml

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: a
  annotations:
    a: "3"

output:

metadata.annotations.a
  ± value change
    - 2
    + 3

Now if I change metadata.name :

app1.yaml:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: a
  annotations:
    a: "2"

app2.yaml

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: b
  annotations:
    a: "3"

output:

(file level)
  - one document removed:       ---                 ⇆ order changed
    ---                         apiVersion: v1        - v1/ConfigMap/a
    apiVersion: v1              kind: ConfigMap       + v1/ConfigMap/b
    kind: ConfigMap             metadata:
    metadata:                   │ name: b
    │ name: a                   │ annotations:
    │ annotations:              │ │ a: 3
    │ │ a: 2

Expected output:

metadata.annotations.a
  ± value change
    - 2
    + 3

metadata.name
  ± value change
    - a
    + b
cbcheck24 commented 2 months ago

Yeah same issue here, its refusing to actually diff two files that have minor differences and just says order changed + one document removed