Repository navigation
line output: only list files that actually changed - #336
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
The single line output format was iterating over every file it processed, so running yamlfmt -output_format line on a directory where only one file needs formatting would report every file in that directory as having a formatting difference. Files that are already formatted should not show up here. While at it, sort the paths so the output is stable across runs; previously it depended on Go map iteration order.
The existing line_output case only had a single file that needed formatting, so it never exercised what happens to files that are already formatted. Add one that yamlfmt should leave alone so the output format is checked against a mixed directory.
rootkiller6788
marked this pull request as ready for review
November 10, 2026 05:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While playing with
-output_format lineI noticed it reports files that weren't touched. If you lint a directory where one file needs formatting and ten are already fine, it prints all eleven as "formatting difference found", which makes the output useless for tooling and also flips around between runs because it walks the map directly.The default and gitlab output formats already skip unchanged files and print in a stable order, so this brings the line format in line with them: only report diffs where something actually changed, and sort the paths.
Added a unit test for the single line output and extended the existing line_output integration case with an already-formatted file so this doesn't silently regress.