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

Display text-based diff if yaml/json diff is semantically equal #11803

Merged
merged 1 commit into from Jan 19, 2023

Conversation

aq17
Copy link
Contributor

@aq17 aq17 commented Jan 6, 2023

Fixes #11799

#9380 and #9484 introduced changes that render JSON/YAML parsable strings as objects in diffs – therefore, examples such as"foo:\n bar: {}\n baz: {}\n" and "#foo\nfoo:\n bar: {}\n baz: {}\n" are recognized as equal.

This change causes the display to fall back to showing the text-based diff if the JSON/YAML rendering does not indicate any diff.
It also prints all object keys even if the value is empty, i.e. bar: {} or bar: "" will be printed instead of bar being omitted.

@aq17 aq17 requested a review from dixler January 6, 2023 23:26
@pulumi-bot
Copy link
Contributor

pulumi-bot commented Jan 6, 2023

Changelog

[uncommitted] (2023-01-18)

Bug Fixes

  • [cli/display] Display text-based diff if yaml/json diff is semantically equal
    #11803

Copy link
Member

@lukehoban lukehoban left a comment

Choose a reason for hiding this comment

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

Can we add test coverage for this?

@aq17 aq17 force-pushed the aqiu/11799 branch 2 times, most recently from cb6cff9 to be6ad25 Compare January 13, 2023 21:50
@aq17 aq17 requested a review from iwahbe January 13, 2023 22:10
Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

LGTM

Nit: Let's try to get the correct changelog before we merge.

@aq17
Copy link
Contributor Author

aq17 commented Jan 18, 2023

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 18, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

bors bot added a commit that referenced this pull request Jan 18, 2023
11803: Display text-based diff if yaml/json diff is semantically equal r=aq17 a=aq17

Fixes #11799 

#9380 and #9484 introduced changes that render JSON/YAML parsable strings as objects in diffs – therefore, examples such as`"foo:\n  bar: {}\n  baz: {}\n"` and `"#foo\nfoo:\n  bar: {}\n  baz: {}\n"` are recognized as equal.

This change causes the display to fall back to showing the text-based diff if the JSON/YAML rendering does not indicate any diff.
It also prints all object keys even if the value is empty, i.e. `bar: {}` or `bar: ""` will be printed instead of `bar` being omitted.

Co-authored-by: aq17 <aqiu@pulumi.com>
@bors
Copy link
Contributor

bors bot commented Jan 18, 2023

Build failed:

@aq17
Copy link
Contributor Author

aq17 commented Jan 19, 2023

bors retry

bors bot added a commit that referenced this pull request Jan 19, 2023
11803: Display text-based diff if yaml/json diff is semantically equal r=aq17 a=aq17

Fixes #11799 

#9380 and #9484 introduced changes that render JSON/YAML parsable strings as objects in diffs – therefore, examples such as`"foo:\n  bar: {}\n  baz: {}\n"` and `"#foo\nfoo:\n  bar: {}\n  baz: {}\n"` are recognized as equal.

This change causes the display to fall back to showing the text-based diff if the JSON/YAML rendering does not indicate any diff.
It also prints all object keys even if the value is empty, i.e. `bar: {}` or `bar: ""` will be printed instead of `bar` being omitted.

Co-authored-by: aq17 <aqiu@pulumi.com>
@bors
Copy link
Contributor

bors bot commented Jan 19, 2023

Build failed:

@iwahbe
Copy link
Member

iwahbe commented Jan 19, 2023

bors retry

bors bot added a commit that referenced this pull request Jan 19, 2023
11803: Display text-based diff if yaml/json diff is semantically equal r=aq17 a=aq17

Fixes #11799 

#9380 and #9484 introduced changes that render JSON/YAML parsable strings as objects in diffs – therefore, examples such as`"foo:\n  bar: {}\n  baz: {}\n"` and `"#foo\nfoo:\n  bar: {}\n  baz: {}\n"` are recognized as equal.

This change causes the display to fall back to showing the text-based diff if the JSON/YAML rendering does not indicate any diff.
It also prints all object keys even if the value is empty, i.e. `bar: {}` or `bar: ""` will be printed instead of `bar` being omitted.

Co-authored-by: aq17 <aqiu@pulumi.com>
@bors
Copy link
Contributor

bors bot commented Jan 19, 2023

Build failed:

@aq17
Copy link
Contributor Author

aq17 commented Jan 19, 2023

bors retry

@bors bors bot merged commit 2ef87d8 into master Jan 19, 2023
@bors
Copy link
Contributor

bors bot commented Jan 19, 2023

Build succeeded:

@bors bors bot deleted the aqiu/11799 branch January 19, 2023 23:47
@Frassle Frassle mentioned this pull request Jan 18, 2024
6 tasks
github-merge-queue bot pushed a commit that referenced this pull request Jan 18, 2024
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes #13981.

This regressed in #11803. I've
added tests to this PR to show both the value diffing and text diffing
for when the JSON/YAML string is different but the values are the same.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diff display for string values with YAML contents displays empty objects incorrectly
4 participants