The rbt diff
command allows users to get a preview of the diff that will be posted when they run rbt post
.
It would be nice, when running on a supporting terminal, to apply some basic colorization of the output (in much the same way that git diff
will highlight removed lines in red and added lines in green).
For this, you will want to evaluate the Pygments library, which provides syntax highlighting.
I'm pleased to report that this feature is nearly completed. David and Christian have reviewed it, and all of the issues they reported on the review request have been addressed. Christian suggested adding support for pydiffx's pydiffx.integrations.pygments lexer.DiffXLexer.DiffXLexer
. I've added support for pydiffx and written test cases. However, David and Christian will need to review it to ensure that nothing is missing or overlooked.
The review request can be found here.
Overview of the changes:
rbtools/commands/diff.py
--color-diff
option to rbt diff
command.Diff.colorize_diff
: Formats the diff with basic colorization.**rbtools/commands/tests/test_diff.py**
rbt diff
with various arguments for --color-diff
optionDiff.colorize_diff
using a unified diff.Diff.colorize_diff
using diffx.rbtools/testing/testcase.py
_capture_sys_output
: Context manager to capture the sys.stderrTo do: