yamlfix
yamlfix copied to clipboard
Feature: Output differences
Description
Add ability to print changes on stdout for pipelines
Possible Solution
Preferably would add to --check
to output the changes, so that can be consumed and added to a merge request comment
Alternatively add a --diff
that would combine --check
and the output
Additional information
This could work similarly to how black
uses --diff
https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#diffs
Hi @babyhuey, thanks for taking the time to open an issue.
We already have a --check
flag for the command that is used by the pre-commits to check if the file will be changed. If it needs changes it will return a status code different than 0
.
If you only want to show the formatted result of a file you can always do cat file.yaml | yamlfix -
. To show the differences you could use git diff
on the output.
To be able to add this enhancement we'd need to be able to match the original lines with the changed ones, which I don't feel it's easy with the current codebase. Thus I'm afraid that adding the logic inside yamlfix
will add a lot of unneeded complexity when there are existent tools that already do that job.
I'm inclined then to close the issue as won't fix
, but I wanted to know your opinion. Will the suggested workflows with cat
, git
and the existent --check
flag work for you? If not, how would you propose to implement the feature? And are you willing to make a pull request?
Thanks!
Hmm, that's fair.
I will see if I can figure something out and open a PR, if not, just using git diff might work.
Thanks!
On Tue, Dec 20, 2022 at 8:04 AM Lyz @.***> wrote:
Hi @babyhuey https://github.com/babyhuey, thanks for taking the time to open an issue.
We already have a --check flag for the command that is used by the pre-commits to check if the file will be changed. If it needs changes it will return a status code different than 0.
If you only want to show the formatted result of a file you can always do cat file.yaml | yamlfix -. To show the differences you could use git diff on the output.
To be able to add this enhancement we'd need to be able to match the original lines with the changed ones, which I don't feel it's easy with the current codebase. Thus I'm afraid that adding the logic inside yamlfix will add a lot of unneeded complexity when there are existent tools that already do that job.
I'm inclined then to close the issue as won't fix, but I wanted to know your opinion. Will the suggested workflows with cat, git and the existent --check flag work for you? If not, how would you propose to implement the feature? And are you willing to make a pull request?
Thanks!
— Reply to this email directly, view it on GitHub https://github.com/lyz-code/yamlfix/issues/194#issuecomment-1359321728, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3EPN5ZM7YAEZAIVJIMVGLWOGVEBANCNFSM6AAAAAATDZD7YY . You are receiving this because you were mentioned.Message ID: @.***>