yq
yq copied to clipboard
headComment is added after the field instead of before
Describe the bug When setting headComment, the comment is added after the field or inside the object instead of being prepended above the field.
Version of yq: 4.7.0 (also failed on 4.5.1) Operating system: mac Installed via: homebrew
Example 1
Input Yaml
foo:
default: bar
description: baz
Command
yq e -P '.[] headComment |= .description | .[] |= .default'
Actual behavior
foo: bar
# baz
Expected behavior
# baz
foo: bar
Example 2:
Input Yaml
foo:
default:
qux: quo
description: baz
Command
yq e -P '.[] headComment |= .description | .[] |= .default'
Actual behavior
foo:
# baz
qux: quo
Expected behavior
# baz
foo:
qux: quo
This is a problem with the underlying go-yaml parser - it's not very good at placing comments correctly :(
Looks related to https://github.com/go-yaml/yaml/issues/695
Possibly https://github.com/go-yaml/yaml/issues/610