Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MergeYaml block indentation not as expected #4358

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

pstreef
Copy link
Contributor

@pstreef pstreef commented Jul 25, 2024

I think I have identified a bug in the yaml parser + writer.
when we parse the following yaml:

some:
  object:
    script: |
      #!/bin/bash
      echo "hello

the value of the script mapping is:

      #!/bin/bash
      echo "hello

when writing this yaml it correctly writes back as the original because of this.
However, when we want to insert this yaml somewhere into another document the prefix is not taken into account. So if I were to insert

script: |
  #!/bin/bash
  echo "hello

into the same spot I end up with:

some:
  object:
    script: |
  #!/bin/bash
  echo "hello

I think we should remove the whitespace from the block values and use the prefix of the parent (in case of a LITERAL or FOLDER style scalar) to indent when printing

It might be better to add the current indentation to the printer context.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

@timtebeek timtebeek added the bug Something isn't working label Jul 26, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-gradle/src/main/groovy/RewriteSettings.groovy
    • lines 31-36

johnpaulms and others added 4 commits July 31, 2024 08:37
* Added test cases to check inline comment retention.

* Updated issue number to check inline comment retention.

---------

Co-authored-by: j0m17kw <johnpaul.manohar@walmart.com>
Co-authored-by: Peter Streef <peter@moderne.io>
@pstreef pstreef closed this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants