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

Merged
merged 25 commits into from
Nov 25, 2024

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

@sambsnyd
Copy link
Member

I merged main into that WIP branch, but I did it in the web interface and it looks like I misplaced a bit of syntax so it isn't compiling anymore. Whoops 😅

@jevanlingen jevanlingen force-pushed the fix/merge-yaml-block-indentation branch from 6201fbc to bdc90bf Compare November 22, 2024 10:45
@jevanlingen
Copy link
Contributor

@sambsnyd I cleaned it up by going back to main and applying all the changes from another working branch (4358-fix-MergeYaml-block-indentation-not-as-expected). So now it can be reviewed.

pstreef and others added 9 commits November 25, 2024 08:45
* Added test cases to check inline comment retention.

* Updated issue number to check inline comment retention.

---------

Co-authored-by: j0m17kw <[email protected]>
Co-authored-by: Peter Streef <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jevanlingen jevanlingen force-pushed the fix/merge-yaml-block-indentation branch from 33e702b to 9b8c2af Compare November 25, 2024 07:45
@jevanlingen jevanlingen marked this pull request as ready for review November 25, 2024 08:40
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Great to see! Approved already with three minor suggestions/questions. Merge once those are resolved.

@timtebeek timtebeek merged commit 615a767 into main Nov 25, 2024
2 checks passed
@timtebeek timtebeek deleted the fix/merge-yaml-block-indentation branch November 25, 2024 12:54
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.

5 participants