-
Notifications
You must be signed in to change notification settings - Fork 0
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
Option to ignore merge keys? #32
Comments
I guess we can do some sorting, e.g. when given: data:
d: d
a: a
<<: *foo
c: c
b: b we can generate: data:
a: a
d: d
<<: *foo
b: b
c: c That is sort each group of items between the beginning of a dictionary, the end of a dictionary, or a reference. Would that work for you? Do you see any pitfall? |
@smortex I think I would prefer to sort the merge keys to the top of the hash, then sort the rest. So something like this: data:
<<: *foo
a: a
b: b
c: c
d: d Reason being that we do not know exactly what is being merged, plus I think it's the idiom to keep merge keys to the top. @OtherCroissant what do you think? |
In that case, that would break things like: foo: &foo
a: 42
data:
d: d
a: a
<<: *foo
c: c
b: b here, foo: &foo
a: 42
data:
<<: *foo
a: a
b: b
c: c
d: d Also, the "correct" sorting should output |
I agree that changing the position of the merge will change its meaning and outcome of the evaluation. Keeping the merge keys on top of the list could also be seen as a convention and the rest still works if the suggested group sorting is implemented. |
@smortex ah, you are right, I did not consider the overriding of existing keys. Then yeah, your proposed solution is the best one. Keep the merge keys on top. |
Right now, when you try to sort a YAML file that contains a merge key using, e.g., a YAML alias, you get the following error message:
An option to ignore such merge keys would be nice to have. Now YAML files containing merge keys cannot be sorted at all.
The text was updated successfully, but these errors were encountered: