-
Notifications
You must be signed in to change notification settings - Fork 56
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
List item diff should preserve order #59
Comments
Yeah, that is a little odd. I was iterating backward through lists so that when a diff is adding or removing something from the end of a list, it can still be applied linearly. An important invariant is that the diff can be applied with the patch operation to get the original value. And diffs are always applied one hunk at a time. I've just finished refactoring the diff format on the And I'm glad this tool was helpful! :) |
Hi @josephburnett, I'm running into perhaps a similar issue: when applying a patch the original structure, newlines and comments are not preserved.
deployment:
replicaCount: 1
strategy:
type: RollingUpdate
maxUnavailable: 0
maxSurge: 12%
# comment
podTemplate:
containers:
amazing-app:
image:
tag: 6.1.4
env:
FOO: bah
resources: {}
hpa:
enabled: false
maxReplicas: 10
ingress:
enabled: false
scheme: internal
deployment:
replicaCount: 1
strategy:
maxSurge: 12%
maxUnavailable: 0
type: RollingUpdate
hpa:
enabled: false
maxReplicas: 10
ingress:
enabled: false
scheme: internal
podTemplate:
containers:
amazing-app:
env:
FOO: bar
image:
tag: 6.1.4
resources: {} Is there a way to preserve the original file's formatting? |
@philpennock I've finally merged my v2 branch to master. The tool has a new flag
@ [0,"extra"]
- "a"
@ [0,"value"]
- 42
+ 44
@ [1,"value"]
- 35
+ 37
@ [1,"extra"]
+ "b" It's not published in a version yet, but you can play around with it by running jd from source. I'll let you know when I publish a new version. It will be in the 1.y.z series because |
@dudicoco unfortunately jd only uses the subset of YAML which is compatible with JSON. Because this is primarily a JSON diff tool. JSON doesn't support comments :( so this tool doesn't either. This isn't related to this reported issue. But you are welcome to open a feature request if you like. That will help me understand how many people want preservation of YAML comments. |
@philpennock I've release the 2.0 version which is default. So this should be fixed now! |
(First, thank you for this tool, it's very helpful in double-checking that correct fields have been changed! Made my day.)
Given a top-level list, each member of which is an object, when generating a diff the diff is emitted in reverse order. This is contrary to my expectations.
Eg, given
old.json
ofand
new.json
of:then at present (jd version 1.7.1), we see:
I would expect the items to be shown in increasing index order, normally.
The text was updated successfully, but these errors were encountered: