feat: add colorized option for highstate output#68982
Open
mdschmitt wants to merge 2 commits into
Open
Conversation
10dc1af to
a45beb9
Compare
Colorize unified diffs in the highstate outputter: added lines are green, removed lines are red, hunk headers are cyan, and context lines are gray. `newfile:` and other change keys are rendered with the same indentation as the current functionality provides.
a45beb9 to
8dea3a0
Compare
- Black reformat the lines.extend() generator call in _render_changes_dict - Replace U+2192 arrows in _render_diff docstring with ASCII -> so the cp1252 docstring-encoding hook passes (these characters break salt-run -d and salt -d on Windows where stdout uses the locale-default encoding)
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.
What does this PR do?
Adds optional colorization for diff chunks in the highstate output module.
disclaimer: I used AI to assist me in creating and testing this code, but it works appropriately as far as I can tell. The original version I had wasn't nearly as clean and smooth as this ended up.
I had some trouble getting all the pre-commit hooks to play nice on my Fedora laptop but I'm fairly sure that a workflow run will succeed. I'll obviously make changes if that's not the case.
What issues does this PR fix or reference?
I didn't submit an issue for this; I did however mention it a while back in Discord.
This is me attempting to upstream the polished final result.
Previous Behavior
All diff output in highstate output module was green regardless of additions/deletions
New Behavior
If specified, the full_color, changes_color and such output modes will show a colorized diff in the state return output (such as for
file.managed). The results are colorized like so:Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No, but signed with ssh key (so it looks like GitHub itself re-signed it with gpg key ID
B5690EEEBB952194)