Skip to content

headComment is added after the field instead of before #788

Open
@ben-turner

Description

@ben-turner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions