yaml-diff icon indicating copy to clipboard operation
yaml-diff copied to clipboard

bug with yaml long string

Open zhaogaolong opened this issue 1 year ago • 1 comments

I want diff long string values, but give wrong result

test case

c.yaml

data:
  config: |
    logging.a: false
    logging.b: false

d.yaml

data:
  config: |
    logging.a: false
    logging.c: false

the d.yaml delete logging.b: false and add logging.c: false

but result:

--- example/c.ymal
+++ example/d.yaml

  data:
-   config: "logging.a: false
logging.b: false
"
+   config: "logging.a: false
logging.c: false

"

The correct result is 图片

ref:

  • https://www.yamldiff.com/

zhaogaolong avatar Feb 20 '24 05:02 zhaogaolong

@zhaogaolong

I fixed partially this issue. It is string handling issue when dump diff. ref. https://github.com/sters/yaml-diff/commit/80c22c77e46b138514b174ad92c12ff9ef992cfa

So far, this yaml-diff only handles key-value pair and structure. It means showing "There is a diff in the key" even if there is multiline strings. This is because go-yaml that is yaml parser used in yaml-diff only has the information that it is a string. Maybe a custom type could be used to get a more detailed diff as you mentioned, with the information that it is a multi-line string. Or, maybe re-calculate detailed diff if the diff is in string values in dump phase.

sters avatar Mar 01 '24 13:03 sters