kworkflow / patch-hub

patch-hub is a TUI that streamlines the interaction of Linux developers with patches archived on lore.kernel.org
GNU General Public License v2.0
7 stars 6 forks source link

feat: adds renderers for patch preview #49

Closed OJarrisonn closed 1 month ago

OJarrisonn commented 1 month ago

In this draft PR i've introduced two options of prerenderers for patches: bat and delta.

Both are external tools, bat is a modern cat implementation, while delta is a diff rewrite (both written in Rust, not a coincidence). They provide some cool syntax highlight ans some other layout stuff that improves the experience of reading long patch files.

In order to achieve this, i've done 2 major changes in patch-hub. The changes are:

The next step is to add a config option to customize the renderers. But here comes a design decision that is really important: how customizable shall the renderers be?

Currently i have hardcoded both bat and delta rendering just for testing the feature. I could hardcode some more (say diff-so-fancy) and let the user choose from one of our curated options. But we could also let the user fully customize the renderer by providing the rendering command.

The first option is my favorite since patch-hub is a productivity tool that isn't meant to be fully customizable, so providing some different predefined options for preview is probably best. Also let the user add a couple extra flags would be interesting (delta has a --diff-so-fancy flag to change the layout a bit, bat has a --language flag that support custom syntax highlighting using a user defined syntax).

The second option require full documentation on how to create a good rendering command, which flags/modes would be nice, etc.

I'm leaning hard towards the first option but i want some feedback.

Example

Here is some example of what it currently looks like

Bat

Some pretty colors to help visualization of the diff syntax

image

Delta

More advanced syntax highlight and layout (some hardcore users might dislike)

image

OJarrisonn commented 1 month ago

'Now this feature is ready for merge. Just some more changes:

davidbtadokoro commented 1 month ago

Hey @OJarrisonn, thank you really, really (really!) much for the marvelous (and I don't say it lightly) work!

As I talked with you offline, I've made a handful of changes to this PR, almost all of them "bureaucratic" in the sense that they pertain to commit order/atomicity/descriptions. Besides dropping the last commit about formatting (since I've applied formatting commit by commit), I think all of the adaptations I've done are described in each commit Maintainer edits section.

In any case, thanks for the wait and the great implementation! Change merged into the unstable branch :+1: